forked from Hacker233/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (68 loc) · 1.77 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>轮播图</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="wrap">
<ul id="content">
<li><img src="images/1.jpg" alt=""></li>
<li><img src="images/2.jpg" alt=""></li>
<li><img src="images/3.jpg" alt=""></li>
<li><img src="images/4.jpg" alt=""></li>
<li><img src="images/5.jpg" alt=""></li>
<li><img src="images/6.jpg" alt=""></li>
</ul>
<ul id="tips">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
<script src="js/move.js"></script>
<script>
var wrap=document.getElementById('wrap');
var content=document.getElementById('content');
var tips=document.getElementById('tips');
var aLi=tips.getElementsByTagName('li');
var now=0;
for(var i=0;i<aLi.length;i++)
{
aLi[0].className="active";
content.style.left=0+"px";
aLi[i].onclick=function() {
now=this.index;
play();
}
}
function play() {
for(var j=0;j<aLi.length;j++)
{
aLi[j].className="";
}
aLi[now].className="active";
startMove(content,{left: -400 * now,});
}
function autoPlay() {
now++;
if(now==aLi.length)
{
now=0;
}
play();
}
var timer=setInterval(autoPlay,2000);
wrap.onmouseover= function () {
clearInterval(timer);
}
wrap.onmouseout=function() {
timer=setInterval(autoPlay,2000);
}
</script>
</body>
</html>