I'm trying to implement a search for a table, I found an answer on the web and I tried it out, it works fine!
now I want to highlight (change text colour: text colour class = blue-text) that search keyword found in a table cell, I searched for this answer but I didn't find anything helpful!
my HTML is
<table class="stdtable">
<tr>
<td id="stdname">Name</td>
<td id="stdreg">Reg. No.</td>
<td id="stdparent">Parent</td>
<td id="stdgrp">Group</td>
<td id="action">Action</td>
</tr>
</table>
and Jquery is
$("#filter").on("keyup", function() {
var searchKey = $(this).val().toLowerCase();
$(".stdtable tr #stdname").each( function() {
var searchStr = $(this).text().toLowerCase();
if (searchStr.indexOf(searchKey)!=-1) {
$(this).parent().show();
}
else {
$(this).parent().hide();
}
});
});
how can I highlight the searched text? if I search N the text N in Name should change the colour
and if I clear the search field I need to clear colour of the text also