Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. var arr = [2,5,8,11,14,17,....];
  2.  
  3. <ul>
  4. <li>testing</li>
  5. <li>testing</li> // -->2nd li be green
  6. <li>testing</li>
  7. <li>testing</li>
  8. <li>testing</li> // -->5th li be green
  9. <li>testing</li>
  10. <li>testing</li>
  11. <li>testing</li> // -->8th li green like this
  12. <li>testing</li>
  13. <li>testing</li>
  14. <li>testing</li>
  15. <li>testing</li>
  16. <li>testing</li>
  17. <li>testing</li>
  18. </ul>
  19.  
  20. arr.forEach(function(num){
  21. $('ul li').eq(num + 1).css('backgroundColor', 'green');
  22. });
  23.  
  24. li:nth-child(2) {
  25. background: #ff0000;
  26. }
  27.  
  28.  
  29. li:nth-child(3n+0) {
  30. background: #ff0000;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement