复制代码 代码如下:
<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>
<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取模,求余数
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“js取模(求余数)隔行变色”评论...