[javascript]定时变换图片

<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<script>
y=1;
function imgs()
{
    var myImg=document.getElementsByTagName("img")[0];
    myImg.src=y+".jpg";
    if(y==2)y=1;
    else y++;
}
</script>
</head>
<body onload="setInterval(imgs,1000);">
<div align="center">
<img src="1.jpg">
</div>
</body>
</html>

 

posted @ 2013-03-16 15:21  Myths  阅读(266)  评论(0编辑  收藏  举报