-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (51 loc) · 967 Bytes
/
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
/*
var i = 0;
i++;
if( i === 5 ){
i = 0;
}
i%=5;
*/
window.onload = function (){
var aLi = document.getElementsByTagName('li');
var arr = [ 'red', 'yellow', 'blue' ];
for (var i = 0; i < aLi.length; i++) {
aLi[i].index=i;
aLi[i].style.background=arr[i%arr.length];
aLi[i].onmouseover=function(){
this.style.background="#ccc";
};
aLi[i].onmouseout=function(){
this.style.background=arr[this.index%arr.length]
}
};
};
</script>
<style>
li { height:24px; margin-bottom:3px; list-style:none; }
</style>
</head>
<body>
<ul id="ul1">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>