这篇文章总字数为:632 字,有 1 张图存于本站服务器
作业预览:
实现代码:
<html>
<head>
<meta charset="UTF-8" />
<title>17180***匿名者简易幻灯片</title>
<script>
var curIndex = 0;
var timeInterval = 2000;
var arr = new Array();
arr[0] = "images/1.jpg";
arr[1] = "images/2.jpg";
arr[2] = "images/3.jpg";
arr[3] = "images/4.jpg";
arr[4] = "images/5.jpg";
setInterval(changeImg,timeInterval);
function changeImg() {
var obj = document.getElementById("obj");
if (curIndex == arr.length-1) {
curIndex = 0;
} else {
curIndex += 1;
}
obj.src = arr[curIndex];
}
</script>
</head>
<body>
<img id = "obj" src = "images/1.jpg" style="width:500px;height:500px;" />
</body>
</html>
作业分享者:
该作业由匿名同学提供,感谢分享。
文明借鉴,站在巨人肩膀上创造价值。
评论