JS效果:手风琴

bor

我觉得这个更无聊了

代码如下:

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
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin:0;
padding:0;
}
ul li{
list-style: none;
float: left;
width: 240px;
height: 400px;
}
ul{
width: 1300px;
}
div{
width:1150px;
height: 400px;
margin:50px auto;
overflow: hidden;
border:1px solid red;
}
</style>
<script src="js/myJquery1.4.js"></script>
</head>
<body>
<div>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<script>
//给所有的li添加背景图
var div = document.getElementsByTagName('div')[0];
var ul = div.children[0];
var liArr = ul.children;
for(var i=0;i<liArr.length;i++){
liArr[i].style.background = "url(images/player/"+(i+1)+".jpg)";
//鼠标移入li,这个li宽度变为800,其他的li变100;
liArr[i].onmouseover = function(){
for(var j=0;j<liArr.length;j++){
animation(liArr[j],{"width":"100px"});
}
animation(this,{"width":"800px"})
}
//鼠标移出li,这个li变回原样240
liArr[i].onmouseout = function(){
for(var j=0;j<liArr.length;j++){
animation(liArr[j],{"width":"240px"});
}
}
}

</script>
</body>
</html>

文章目录
  1. 1. bor
|