WEB前端:06_accordion手风琴效果
2020-12-13 02:35
阅读:297
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:style blog class code java ext
accordion手风琴效果
网站常用效果之一,以下为简化版,用于学习javascript基础知识。
效果图:
accordion手风琴效果 - 纯js简化版
?
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
|
>
*{margin: 0; padding: 0;} #acclist {list-style: none; width: 400px; margin: 10px; padding: 0;} #acclist li { background: #ccc; list-style: none; margin: 0 0 1px 0; padding: 0;} #acclist li h3 {font-size: 13px; color: #fff; background: #666; padding: 5px;cursor:pointer;} #acclist li div { display: none; padding: 5px; height: 80px;}
>
window.onload = function () {
var
acc = document.getElementById( ‘acclist‘ );
var
accli = acc.getElementsByTagName( ‘li‘ );
for ( var
i=0; i
accli[i].getElementsByTagName( ‘h3‘ )[0].index = i;
accli[i].getElementsByTagName( ‘h3‘ )[0].onmouseover = function () {
for ( var
a=0; a
accli[a].getElementsByTagName( ‘div‘ )[0].style.display = "none" ;
}
if (accli[ this .index].getElementsByTagName( ‘div‘ )[0].style.display == "block" ) {
accli[ this .index].getElementsByTagName( ‘div‘ )[0].style.display = "none" ;
} else
{
accli[ this .index].getElementsByTagName( ‘div‘ )[0].style.display = "block"
}
}
}
accli[0].getElementsByTagName( ‘div‘ )[0].style.display = "block" ;
}
|
WEB前端:06_accordion手风琴效果,搜素材,soscw.com
WEB前端:06_accordion手风琴效果
标签:style blog class code java ext
原文地址:http://www.cnblogs.com/haicheng/p/3718869.html
评论
亲,登录后才可以留言!