jQuery(document).ready(function($) { $("#filterVar1").keyup(function(){ // Retrieve the input field text and reset the count to zero var filter = $(this).val(), count = 0; // Loop through the product list $(".products .entry.product_cat-var1").each(function(){ // If the list item does not contain the text phrase fade it out if ($(this).text().search(new RegExp(filter, "i")) < 0) { $(this).hide(); // Show the list item if the phrase matches and increase the count by 1 } else { $(this).show(); count++; } }); // Update the count //var numberItems = count; $("#filter-count-var1").text(count+" Results"); }); $("#filterVar1").keyup(); $("#filterVar2").keyup(function(){ // Retrieve the input field text and reset the count to zero var filter = $(this).val(), count = 0; // Loop through the product list $(".products .entry.product_cat-var2").each(function(){ // If the list item does not contain the text phrase fade it out if ($(this).text().search(new RegExp(filter, "i")) < 0) { $(this).hide(); // Show the list item if the phrase matches and increase the count by 1 } else { $(this).show(); count++; } }); // Update the count //var numberItems = count; $("#filter-count-var2").text(count+" Results"); }); $("#filterVar2").keyup(); });