Posted By

zayyarphone on 11/04/10


Tagged

filterjquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kubaitis


jquery simple regexp filter


 / Published in: jQuery
 

URL: http://www.mattryall.net/blog/2008/07/jquery-filter-demo

  1. $("#filter").keyup(function () {
  2. var filter = $(this).val(), count = 0;
  3. $(".filtered:first li").each(function () {
  4. if ($(this).text().search(new RegExp(filter, "i")) < 0) {
  5. $(this).addClass("hidden");
  6. } else {
  7. $(this).removeClass("hidden");
  8. count++;
  9. }
  10. });
  11. $("#filter-count").text(count);
  12. });

Report this snippet  

You need to login to post a comment.