[javascript]代码库
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<style type="text/css">
ul{width:100px;}
li{list-style:none;float:left;width:50px;height:25px;}
</style>
<script type="text/javascript">
function t(){
var a=document.getElementsByTagName('li');
var id=0;
for(var i=0;i<a.length;i++){
id=i+1;
if(Math.ceil(id/2)%2){
a[i].style.background='red';
}else{
a[i].style.background='pink';
}
}
}
</script>
</head>
<body onload="t();">
<div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
</body>
</html>