I'm using the following to sequentially change the background color of some list items. It works, but is there a direct way of putting a variable inside the n-th child parentheses, instead of concatenating? Second question, more CSSey, though. The highlight goes all the way across the page since the CSS bounding box is 100% for the li items. The lines are various lengths so I can't just set the bounding box to, say, fifty percent. Is there a way to use jQuery to make the bounding box, or background color only go to the end of the text?
jQuery(function(){
- var x = 1;
- jQuery(document).everyTime(2000,function(){
- jQuery("li:nth-child(" + x++ + ")").css("background-color","yellow"); },10);
- }
- );