-
Notifications
You must be signed in to change notification settings - Fork 0
/
togglesample.html
68 lines (58 loc) · 1.46 KB
/
togglesample.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="./libs/js/main.js"></script>
<script type="text/javascript" >
$(document).ready(function() {
$('#open_button').click(function(){
$(this).toggleClass('dis_css');
})
$('#slide_toggle_button').click(function(){
$('.children2').slideToggle();
})
$('#fade_toggle_button').click(function(){
$('.children3').fadeToggle();
})
});
</script>
<style type="text/css">
.children, .children2, .children3{
display: none;
}
.dis_css + .children{
display: block;
}
#toggle_check:not(:checked) +label .close{
display: none;
}
#toggle_check:checked + label .open {
display: none;
}
</style>
<body>
<div class="sample">
<p>通常のtoggleを使う</p>
<button id="open_button">開けゴマ</button>
<div class="children">
ボタンを押すと開閉します
</div>
<p>slideToggleを使う</p>
<button id="slide_toggle_button">開けゴマ</button>
<div class="children2">
ボタンを押すと開閉します
</div>
<p>fadeToggleを使う</p>
<button id="fade_toggle_button">開けゴマ</button>
<div class="children3">
ボタンを押すと開閉します
</div>
<p>CSSのみでのtoggle</p>
<input type="checkbox" id="toggle_check" style="display: none;">
<label for="toggle_check">
<span class="open">開け</span>
<span class="close">閉じろ</span>
</label>
</div>
</body>
</html>