Result
jQuery
$('li').each(function(index){ //3つごとに設定 if(Math.floor(index/3)%2==0){ //classを付加 $(this).css('color','blue'); }else{ $(this).css('color','red'); }; });
html
<ul> <li>list01</li> <li>list02</li> ・ ・ ・ <li>list14</li> <li>list15</li> <li>list16</li> </ul>
via
How to target list items per two lists instead of even or odd – Stack Overflow