-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo1.html
72 lines (67 loc) · 2.22 KB
/
demo1.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
71
72
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
li{
background: red;
background: #cccccc;
}
</style>
</head>
<body>
<ul>
<li style="color: red; color: blue;">1</li>
<li>2</li>
<li>3</li>
</ul>
<script>
function count() {
var arr = [];
for (var i=1; i<=3; i++) {
arr.push(function () {
return i * i;
});
}
return arr;
}
var results = count();
var f1 = results[0];
var f2 = results[1];
var f3 = results[2];
/* var oli = document.getElementsByTagName('li')
var oul = document.getElementsByTagName('ul')[0]
var color = ['rgb(159,131,145)', 'rgb(74,192,235)', 'rgb(110,128,191)']
var ab = ''//设置一个变量为空把每一次的颜色给它
for (i = 0; i < 30; i++) {
oul.innerHTML += '<li style="background: ' + color[i % color.length] + '">' + (i + 1) + '</li>'
}
for (m = 0; m < oli.length; m++) {
oli[m].onoff = false //定义一个自定义属性为假
oli[m].onmouseover = function () { //鼠标悬浮时的事件
ab = this.style.background //把每一次的颜色给他,存储颜色
if(!this.onoff){ //当为真的时候鼠标悬浮有高光
this.style.background = 'rgb(237,129,172)'
}
}
oli[m].onmouseout = function () { //鼠标离开时的事件
this.style.background = ab //它的颜色变回原来的了
}
oli[m].onclick = function () { //鼠标点击时的事件
for (n = 0; n < oli.length; n++) {
/*ab=this.style.background*/
/* oli[n].style.background = color[n % color.length] //清空变回原来的颜色
oli[n].onoff = false //为假
}
this.onoff = true //鼠标点击之后为真,鼠标悬浮就不能有高光了
this.style.background = 'blue' //这个颜色为蓝色
ab = 'blue'
}
}*/
/* var arr = [{name: "尼玛", age: 22}, {name: "尼美", age: 20}];
for (var i=0; i<arr.length; i++) {
console.log(arr[i]);
}*/
</script>
</body>
</html>