Posts by Pilati • 1,065 points
52 posts
-
4
votes3
answers241
viewsA: Condition within a . each()
$('li').each(function(index,value){ if(index%3==0){ $(this).css('color','red'); } else if (index%3==1){ $(this).css('color','blue'); } else if (index%3==2){ $(this).css('color','green'); } }) Would…
-
1
votes3
answers171
viewsA: How to simplify this comparison?
I can’t think of an alternative to successive comparisons. The best thing to do would be to put each comparison on a different line as in the case below, but only improve visibility: bool b = (…