I found a Jquery script that does the table filtering stuff based on input field. This script basically takes the filter, splits each word and filters table rows with each w
nrodic has an amazing answer, and I just wanted to give a small update to let you know that with a small extra function you can extend the contains methid to be case insenstive:
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
tr:not(:contains(.... work for me
function busca(busca){
$("#listagem tr:not(:contains('"+busca+"'))").css("display", "none");
$("#listagem tr:contains('"+busca+"')").css("display", "");
}
There's no need to build an array. You can address the DOM directly.
Try :
rows.hide();
$.each(data, function(i, v){
rows.filter(":contains('" + v + "')").show();
});
DEMO
To discover the qualifying rows without displaying them immediately, then pass them to a function :
$("#searchInput").keyup(function() {
var rows = $("#fbody").find("tr").hide();
var data = this.value.split(" ");
var _rows = $();//an empty jQuery collection
$.each(data, function(i, v) {
_rows.add(rows.filter(":contains('" + v + "')");
});
myFunction(_rows);
});
UPDATED DEMO