-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_listColorChange.html
More file actions
72 lines (66 loc) · 2.14 KB
/
Copy pathexample_listColorChange.html
File metadata and controls
72 lines (66 loc) · 2.14 KB
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
<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container{
display: flex;
justify-content: center;
}
ul li{
display: inline-block;
height: 27px;
border-bottom: none;
color: #666;
margin-right: 10px;
}
</style>
</head>
<body>
<div class="container">
<ul>
<li>리빙</li>
<li>푸드</li>
<li>스포츠</li>
<li>자동차</li>
<li>패션뷰티</li>
<li>부모i</li>
<li>건강</li>
<li>웹툰</li>
<li>게임</li>
<li>TV연예</li>
</ul>
</div>
<script>
let colorArray=['#829c00','#ff8624','#2565d0','#058e42','#ff629c','#efae00','#fc5a58','#00b336','#00bbc3','#07bc88',];
let list = document.querySelectorAll(".container ul li");
// for(let i=0;i<list.length;i++){
// list[i].addEventListener("mouseover", () => {
// for(let j=0;j<list.length;j++){
// list[j].style.height = "27px";
// list[j].style.borderBottom = "none";
// list[j].style.color = "#666";
// }
// console.log(list[i]);
// list[i].style.height = "30px";
// list[i].style.borderBottom = `3px solid ${colorArray[i]}`;
// list[i].style.color = `${colorArray[i]}`;
// })
// }
list.forEach((value,i) => {
value.addEventListener("mouseover", () =>{
list.forEach((value2) => {
value2.style.height = "27px";
value2.style.borderBottom = "none";
value2.style.color = "#666";
})
value.style.height = "30px";
value.style.borderBottom = `3px solid ${colorArray[i]}`;
value.style.color = `${colorArray[i]}`;
})
})
</script>
</body>
</html>