-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex-076.html
81 lines (66 loc) · 1.37 KB
/
ex-076.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
<!DOCTYPE html>
<html>
<head>
<title>[實作] 伸縮子選單</title>
<style type="text/css">
.nav{
width: 300px;
}
.lead{
display: block;
height: 60px;
line-height: 60px;
background-color: #ddd;
padding-left: 20px;
font-size: 26px;
cursor: pointer;
border-bottom: 1px solid #999;
}
.lead:hover{
background-color: #aaa;
color: #fff;
}
ul{
margin: 0 0 0.5em 0;
padding: 0;
display: block;
list-style: none;
background: #eee;
}
li{
display: block;
height: 50px;
line-height: 50px;
padding-left: 15px;
border-bottom: 1px solid #333;
}
</style>
</head>
<body>
<div class="nav">
<div class="lead" data-lists="abouts">關於我們</div>
<ul class="abouts">
<li>關於我們</li>
<li>聯絡我們</li>
</ul>
<div class="lead" data-lists="talks">講座</div>
<ul class="talks">
<li>iOS App Development (3)</li>
<li>Machine Learning (0)</li>
<li>Ruby (9)</li>
<li>Front End (7)</li>
<li>Ruby on Rails (8)</li>
<li>Git (2)</li>
</ul>
</div>
<script src="scripts/jquery-3.1.0.js"></script>
<script type="text/javascript">
// code here
$('.lead').on('click', function(){
var listname = $(this).data('lists');
console.log(listname);
$(this).parent().children('.'+listname).slideToggle();
});
</script>
</body>
</html>