-
Notifications
You must be signed in to change notification settings - Fork 0
/
sm3testclass.html
93 lines (79 loc) ยท 2.34 KB
/
sm3testclass.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
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
ul {
list-style: none;
}
.tab-menu {
display: flex;
justify-content: space-between;
}
.tab-menu .menu-list {
flex: 1;
background: #ccc;
line-height: 50px;
text-align: center;
color: #fff;
cursor: pointer;
}
.tab-menu .menu-list:not(:last-child) {
border-right: 1px solid #fff;
}
.tab-menu .menu-list.on {
background: #f00;
}
.tab-con {}
.tab-con div {
display: none;
}
.tab-con div.on {
display: block;
font-size: 48px;
}
</style>
</head>
<body>
<div class="tab-menu">
<div class="menu-list on" data-tab="tab1">tab1</div>
<div class="menu-list" data-tab="tab2">tab2</div>
<div class="menu-list" data-tab="tab3">tab3</div>
</div>
<div class="tab-con">
<div data-type="tab1" class="on">11</div>
<div data-type="tab2">22</div>
<div data-type="tab3">33</div>
</div>
<script>
let list = document.querySelectorAll('.menu-list');
let Div = document.querySelectorAll('.tab-con div');
list.forEach(function (e, i) {
e.addEventListener('click', function () {
for (let i = 0; i < list.length; i++) {
Div[i].classList.remove('on');
list[i].classList.remove('on');
}
e.classList.add('on');
document.querySelector(`[data-type="${e.dataset['tab']}"]`).classList.add('on');
})
})
// ์ ์ด์ฟผ๋ฆฌ ๋ฒ์ ผ
/* $('.menu-list').click(function () {
tabName = $(this).data('tab');
$(this).addClass('on').siblings().removeClass('on')
$(`[data-type='${tabName}']`).addClass('on').siblings().removeClass('on')
}) */
</script>
</body>
</html>