May 17, 2015

jQuery contains vs. JavaScript indexOf to filter results

jQuery contains vs. JavaScript indexOf to filter results

$('#sess_input').on('keyup', function(){
var filter = $(this).val();
$("#sess_table .sess_rows").each(function() {
var found = $(this).text().toLowerCase().indexOf(filter);
if(found<0){ $(this).hide(); } else { $(this).show(); } }); if(filter==''){ $('.sess_rows').show(); }

Last updated: May 17, 2015