Richard & F-ES had already pointed better way of doing it. In case you still want to continue current approach, I would suggest you to make use of
jQuery Filters[
^]
Example usage:
<script>
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
Quote:
We use jQuery to loop through each table rows to check if there are any text values that matches the value of the input field. The toggle() method hides the row (display:none) that does not match the search. We use the toLowerCase() DOM method to convert the text to lower case, which makes the search case insensitive (allows "john", "John", and even "JOHN" on search).
if above is still slow, try using mix of
.find
&
.filter
, like:
var allCells = table.find('td');
selectedCells = allCells.filter(....);
Refer:
jQuery find() Method[
^]