<div class="codetitle"> <span><a style="CURSOR: pointer" data="70127" class="copybut" id="copybut70127" onclick="doCopy('code70127')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code70127"> <br><html xmlns="http://www.w3.org /1999/xhtml"><br><head><br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br>< title>js取模隔行变color</title><br><script type="text/javascript"><br>window.onload=function()<br>{<br> var oUl=document.getElementById ('ul1');<br> var aLi=oUl.getElementsByTagName('li');<br><br> for(var i=0; i< aLi .length; i )<BR> {<BR> if (i%2==0) //取模 求余数<BR> {<BR> aLi[i].style.Background='red';<BR> }<BR> }<BR>}<BR>< ;/script><br></script></head><br><body><br><ul id="ul1"><br> <li>webtall</li><br> <li>webtall</li><br> <li>webtall</li><br> <li>webtall</li><br> <li>webtall</li><br> <br> </div>