On Dec 15, 12:53 pm, huntspointer2009 <huntspoin...@gmail.com> wrote: > thanks Virgil, > Is there a way to create the same effect without specifying the ( eq: > (' ') exact location) or (the content that inside) the list item? > because I might be using up hundreds of <ul></ul> unordered lists, > each with a variable number of <li></li> tags?
In each case you've shown us eight items with the following pattern: off, on, on, off, off, on on. off What's the general pattern? Is it that all the "on" ones are in positions matching 4n + 2 or 4n + 3 and all the "off" ones are 4n or 4n + 1? If that's the case then this should do it: $("ul ").each(function() { $(this).find("li:nth-child(4n+2)", "li:nth-child(4n +3)").addClass("color"); }); If not, can you describe the pattern better? -- Scott