<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>js Change color by taking the die and spacing </title><script type="text/javascript">window.onload=function(){ var oUl=document.getElementById('ul1'); var aLi=oUl.getElementsByTagName('li'); for(var i=0; i< aLi .length; i++) { if(i%2==0) //Take the modulus and find the remainder { aLi[i].style.background='red'; } }}</script></script></head><body><ul id="ul1"> <li>webtall</li> <li>webtall</li> <li>webtall</li> <li>webtall</li> <li>webtall</li></ul></body></html>