jquery simple regexp filter


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.