I need to filter the html table. To do this, I created each callback for all the elements trand checked if one of the contains a tr-childrenspecific template.
$("#filter").keypress(function() {
var filter = $(this).val();
$("#table1 tr[data-config]").each(function(){
var val = $(this).find(":contains('" + filter + "')");
if(val.length > 0){
$(this).css("display","table-row");
}else{
$(this).css("display","none");
}
});
});
This works, but is there a function to check if the element contains any text?
At the moment, I get a list of all the elements containing the template, and count if it is greater than zero. Is there a jQuery function that checks if this pattern happens and returns a boolean? A table can contain many rows, and therefore I want as little overhead as possible.
source
share