forked from HuXn-WebDev/HTML-CSS-JavaScript-100-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
18 lines (16 loc) · 583 Bytes
/
app.js
File metadata and controls
18 lines (16 loc) · 583 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let selectField = document.getElementById("selectField");
let selectText = document.getElementById("selectText");
let list = document.getElementById("list");
let arrowIcon = document.getElementById("arrowIcon");
let options = document.getElementsByClassName("options");
selectField.addEventListener("click", () => {
list.classList.toggle("hide");
arrowIcon.classList.toggle("rotate");
});
for (option of options) {
option.onclick = function () {
selectText.innerHTML = this.textContent;
list.classList.toggle("hide");
arrowIcon.classList.toggle("rotate");
};
}