复制代码代码如下:
<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>