I have a javascript loop and want to highlight some numbers
for(i=0;i<=100;i++){
$("#mydiv").append("<span>"+i+"</span>");
}
now i want to select 1,5,9,13,17… every 4th but beginning with 1 and highlight it. every second is easy:
for(i=0;i<=100;i++){
var bool = false;
if(bool){
$("#mydiv").append("<span>"+i+"</span>");
bool = false;
} else {
$("#mydiv").append("<span class='highlight'>"+i+"</span>");
bool = true;
}
}
How can I do this?
I’m surprised that people are recommending nth-child selectors for jQuery but not just straight-up nth-child styling via CSS.
In your stylesheet: