Jquery - How to alternate an :Odd :Even pattern every 4 ?

后端 未结 6 1570
无人及你
无人及你 2021-01-06 03:18

I\'m trying to make a pattern in a layout (see attachment for visualisation) The problem is that using :odd :even doesnt work.

I\'ve tried to make it work by using \

6条回答
  •  迷失自我
    2021-01-06 03:55

    another way to do it would be [not proofed for function but demonstrates the logic]:

     $('div').click(function(e){
      $tester=$(this).children('div.Other').size();
            for(var $j=0;$j<$tester;$j=$j+1){
                          if($j%2==0){
                  $(this).children().eq($j).css(...);
                          }else{
                                  $(this).children().eq($j).css(...);
                          }
            }
    
     });
    

提交回复
热议问题