js让我们一起从基础来学习,我们一点一点的来学习

下边是我写的代码,然后大家看着学习下吧!!!

复制代码 代码如下:

<html>
<head>
<title>js演示</title>
</head>
<body>
<script>
document.write('<table border="1" width="100px" align="center">');
var i=0;
while(i<100){
if(i%10==0){
if(i%20==0)
bg="#cccccc";
else
bg="#ffffff";
document.write('<tr onmouseover="show(this)" onmouseout="onshow(this)" bgcolor="'+bg+'">');
}
document.write('<td>'+i+'</td>');
i++;
if(i%10==0){
document.write("<tr>");
}
}
document.write("</table>")
var ys=null;
function show(obj){
ys=obj.bgColor;
obj.bgColor="red";
}
function onshow(obj){
obj.bgColor=ys;
}
</script>
</body>
</html>

功能很简单,却非常实用,小伙伴们参考下吧。

点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部