jquery - Add zebra striping but ignore hidden elements -


i have following code filters list according class added li element. zebra striping works fine when items showing when filter , lets 1 of list items hidden teh zebra stripe goes out of sync. there way around this?

i have checked post ie did not work jquery table zebra striping hidden rows

thanks.

//filter $("#local-clubs-list li:visible:even").addclass("even");  $('ul#filter a').click(function() {       $(this).css('outline','none');       $('ul#filter .current').removeclass('current');       $(this).parent().addclass('current');        var filterval = $(this).text().tolowercase().replace(' ','-');        $('ul#local-clubs-list li').each(function() {                                          if(!$(this).hasclass(filterval)) {               $(this).fadeout('normal').addclass('hidden');         } else {               $(this).fadein('slow').removeclass('hidden');         }            $("#local-clubs-list li").removeclass("even");           $("#local-clubs-list li:visible:nth-child(even)").addclass("even");     });         return false;   });   $('ul#filter a:eq(0)').trigger('click'); 

what seeing in firbug is

<li class="northern even"> <li class="northern"> <li class="north-dublin hidden even" style="display: none;"> <li class="northern"> <li class="northern even"> <li class="northern"> <li class="northern even"> <li class="northern"> <li class="northern even"> 

for reason hidden doesn't work , had add , remove classes. here fonal code works.

//filter      function zebrarows(selector, classname)     {         $(selector).removeclass(classname).addclass(classname);     }     $('#local-clubs-list li').addclass('visible');      $('ul#filter a').click(function() {           $(this).css('outline','none');           $('ul#filter .current').removeclass('current');           $(this).parent().addclass('current');            var filterval = $(this).text().tolowercase().replace(' ','-');            $('ul#local-clubs-list li').each(function() {                                              if(!$(this).hasclass(filterval)) {                   $(this).fadeout('normal').addclass('hidden');                 $(this).fadeout('normal').removeclass('visible');              } else {                   $(this).fadein('slow').removeclass('hidden');             }           });            $('#local-clubs-list li').removeclass('even');         zebrarows('#local-clubs-list .visible:even', 'even');         $('#local-clubs-list li').addclass('visible');         return false;       });       $('ul#filter a:eq(0)').trigger('click'); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -