js每5秒执行一次事件


<!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">
<head>
<title>无标题页</title>
</head>
<body onload="aa()">
<div id="divID" style="width: 200px; height: 200px">
</div>
</body>
</html>

<script type="text/javascript">
var i = 1;
function aa()
{
if (i ==4) {
i=1;
}
document.getElementById("divID").style.backgroundImage="url(img/"+i+".jpg)";
i++;
}
setInterval(aa, 5000)
</script>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM