mark.js table column highlighting example
This fiddle demonstrates how to use julmot/mark.js with column highlighting
HTML
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/superhero/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/mark.js/8.6.0/jquery.mark.min.js"></script>
<input type="text" name="keyword">
<div class="context">
The fox went over the fence
</div><div class="context2">
The fox went over the fence
</div>
CSS
mark {
padding: 0;
background-color:yellow;
}
.context2 mark {
padding: 0;
background-color: orange;
}
JavaScript
$(function() {
var mark = function() {
// Read the keyword
var keyword = $("input[name='keyword']").val();
// Remove previous marked elements and mark
// the new keyword inside the context
$(".context, .context2").unmark({
done: function() {
$(".context, .context2").mark(keyword);
}
});
};
$("input[name='keyword']").on("input", mark);
});