I have made a script to find strings in table. When it finds it shows the row otherwise hide it. It is working perfectly in Chrome but it is some what lagging in Firefox and Internet Explorer. Is this code good or can it be better ?
$("#searchValue").keyup(function() {
var table = $(this).siblings('table').not(':hidden');
var name = $("#searchValue").val();
if (name === "") {
$(table).find('tr').show();
$(table).trigger('update');
}
else {
name = name.toLowerCase();
var trs = $(table).find('tr').not(':first');
trs.each(function() {
var tr = $(this);
var count = ($(tr).children('td').length);
var suc = -1;
for (var i = 0; i < count; i++) {
var state = $(tr).children("td").eq(i).html();
state = state.toLowerCase();
if (state.match(name)) {
suc = 1;
}
else if (suc !== 1) {
suc = 0;
}
}
if (suc === 1) {
$(tr).show();
}
else {
$(tr).hide();
}
});
$(table).trigger('update');
}
});
Table :
<table id='tableProject' class='tablesorter'>
<thead>
<tr>
<th>Project ID</th>
<th>Customer</th>
<th>Description</th>
<th>Status</th>
<th>Max Hours</th>
<th>Achieved</th>
<th>Difference</th>
</tr>
</thead>
<tbody>
</tbody>
</table>