$(document).ready(function() {
$('#txtID').keyup(function(event) {
var searchKey = $(this).val().toLowerCase();
$("#grdEmployee tr td").each(function() {
var cellText = $(this).text().toLowerCase();
if (cellText.indexOf(searchKey) >= 0) {
$(this).parent().show();
}
else {
$(this).parent().hide();
}
});
});
});
Should work :)
Here
$("#grdEmployee tr td:nth-child(1)")
you'd be getting the first
td
of each row. That's why it is working for the first column. Remove
:nth-child(1)
and check whether it's working or not.
[Update - after the comment]
$("#txtID").keyup(function(){
_this = this;
$.each($("#grdEmployee tbody").find("tr"), function() {
if($(this).text().toLowerCase().indexOf($(_this).val().toLowerCase()) == -1)
$(this).hide();
else
$(this).show();
});
});
-KR