-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path选项卡.html
87 lines (85 loc) · 1.58 KB
/
选项卡.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin:0;
padding:0;
}
ul{
list-style:none;
}
#container{
width:364px;
height:300px;
background-color: green;
margin:200px auto;
}
#container div{
height:269px;
font-size:30px;
text-align:center;
font-weight:bold;
line-height:269px;
display:none;
}
#container .select-div{
display:block;
}
#menu{
height:30px;
border-bottom:1px solid blue;
}
#menu li{
height:30px;
width:120px;
margin-right:2px;
float:left;
text-align:center;
line-height:30px;
background-color: yellow;
font-weight:bold;
cursor:pointer;
color:#000;
}
#menu #menu-last-child{
margin-right:0;
}
#menu .select-menu{
background-color: red;
color:#fff;
}
</style>
</head>
<body>
<div id="container">
<ul id="menu">
<li class="select-menu">HTML</li>
<li>CSS</li>
<li id="menu-last-child">JavaScript</li>
</ul>
<div class='select-div'>html</div>
<div>css</div>
<div>js</div>
</div>
<script>
var oContainer = document.getElementById('container');
var oMenu = document.getElementById('menu');
var aLi = oMenu.getElementsByTagName('li');
var aDiv = oContainer.getElementsByTagName('div');
for(var i = 0; i<aLi.length; i++){
aLi[i].index = i;
aLi[i].onmouseover = function(){
for(var j = 0; j<aLi.length; j++){
aLi[j].className = '';
aDiv[j].className = '';
}
this.className = 'select-menu';
aDiv[this.index].className = 'select-div';
};
}
</script>
</body>
</html>