- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouseImageChange.html
More file actions
Latest commit
87 lines (81 loc) · 1.91 KB
/
Copy pathmouseImageChange.html
File metadata and controls
87 lines (81 loc) · 1.91 KB
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>
<head>
<metacharset="utf-8">
<metahttp-equiv="X-UA-Compatible" content="IE=edge">
<title>容器属性</title>
<linkrel="stylesheet" href="">
<style>
*{
margin:0;
padding:0;
list-style: none;
}
.c_father {
margin-left:33%;
margin-top:5%;
}
#i_smouse{
width:360px;
height:60px;
box-sizing: border-box;
}
.c_bmouse{
height:430px;
width:430px;
margin-bottom:20px;
}
ul{
height:60px;
width:430px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
}
.actived{
border:2px solid #000;
box-sizing: border-box;
}
</style>
</head>
<body>
<divclass="c_father">
<divclass="c_bmouse">
<imgsrc="mouse/big_mouse1.jpg" alt="" id="i_big">
</div>
<divid="i_smouse" class="c_smouse">
<ul>
<li><ahref="http://www.baidu.com"><imgsrc="mouse/small_mouse1.jpg" alt=""></a></li>
<li><imgsrc="mouse/small_mouse2.jpg" alt=""></li>
<li><imgsrc="mouse/small_mouse3.jpg" alt=""></li>
<li><imgsrc="mouse/small_mouse4.jpg" alt=""></li>
<li><imgsrc="mouse/small_mouse5.jpg" alt=""></li>
</ul>
</div>
</div>
<!--
容器属性的用法:
-->
<script>
window.onload=function(){
varoBigImg=document.getElementById('i_big');//获得大图片的标签元素
varbigSrc=oBigImg.getAttribute("src");//获取大图片的src
// oBigImg.setAttribute("src", "mouse/big_mouse2.jpg");
varoSmaImg=document.getElementsByTagName('img');
for(vari=1;i<oSmaImg.length;i++){
oSmaImg[i].index=i;
oSmaImg[i].onmouseover=function(){
varsrc="mouse/big_mouse"+this.index+".jpg";
// console.log(src);
oBigImg.setAttribute("src",src);
this.className="actived";
};
oSmaImg[i].onmouseout=function(){
this.className="";
};
}
};
</script>
</body>
</html>