Grab only 2 items from Jquery Loop

Posted by Bry4n on Stack Overflow See other posts from Stack Overflow or by Bry4n
Published on 2010-05-03T17:52:29Z Indexed on 2010/05/03 17:58 UTC
Read the original article Hit count: 250

Filed under:
|
|

Here is my Jquery

$th.each(function(idx) {
      var notSelected = $(this).text();
      if ((notSelected.indexOf(to) != -1) || (notSelected.indexOf(from) != -1)) {

      if (idx < 10)
      {
         $(this).show();
         // and show its corresponding td
         $td.eq(idx).show();
      }
      }
    }); 

It is part of a tableFilter type function for a HTML table. However I want it to only display only 2 of the results. I tried instantiating some kind of index counter but I was unsuccessful. Any help or thoughts would be appreciated.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about each