原生javascript实现隔行换色
js让我们一起从基础来学习,我们一点一点的来学习
下边是我写的代码,然后大家看着学习下吧!!!
<html>
<head>
<title>js演示</title>
</head>
<body>
<script>
document.write('<tableborder="1"width="100px"align="center">');
vari=0;
while(i<100){
if(i%10==0){
if(i%20==0)
bg="#cccccc";
else
bg="#ffffff";
document.write('<tronmouseover="show(this)"onmouseout="onshow(this)"bgcolor="'+bg+'">');
}
document.write('<td>'+i+'</td>');
i++;
if(i%10==0){
document.write("<tr>");
}
}
document.write("</table>")
varys=null;
functionshow(obj){
ys=obj.bgColor;
obj.bgColor="red";
}
functiononshow(obj){
obj.bgColor=ys;
}
</script>
</body>
</html>
功能很简单,却非常实用,小伙伴们参考下吧。