-
Notifications
You must be signed in to change notification settings - Fork 0
/
隐藏出现事件.html
59 lines (58 loc) · 1.49 KB
/
隐藏出现事件.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src='js/jquery-1.9.1.min.js'></script>
<style>
.hide{
display: none;
}
.show{
display: block;
width: 100px;
height: 100px;
background-color: green;
}
.box1{
width: 100px;
height: 100px;
background-color: red;
}
.box2{
width: 100px;
height: 100px;
background-color: green;
}
</style>
<script>
$(function () {
$('#btn').on('click', function () {
$('#box').toggle();
});
// var btn = document.getElementById("btn");
// var box = document.getElementById("box");
// btn.onclick = function () {
// if (box.className == 'hide') {
// box.className = 'show';
// } else {
// box.className = 'hide';
// }
// }
});
// var btn = document.getElementById("btn");
// var box = document.getElementById("box");
// btn.onclick = function () {
// if (box.className == 'hide') {
// box.className = 'show';
// } else {
// box.className = 'hide';
// }
// }
</script>
</head>
<body>
<div class="box1" id="btn"></div>
<div class="box2" id="box"></div>
</body>
</html>