Posted in Javascript onMay 15, 2014
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js取模隔行变色</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) //取模 求余数 { 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>
js取模(求余数)隔行变色
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@