<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>轮播图</title>
</head>
<body>
<img id="img" src="img/banner_1.jpg" width="100%">
<img id="off" src="img/off.gif">
<script>
var img = document.getElementById("img");
var number = 1;
function fun() {
number++;
if (number>3){
number=1;
}
img.src="img/banner_"+number+".jpg";
}
setInterval(fun,3000);
var off = document.getElementById("off");
function fun2() {
off.src="img/on.gif";
}
setTimeout(fun2,5000);
</script>
</body>
</html> |
|