-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 1.05 KB
/
app.js
File metadata and controls
30 lines (25 loc) · 1.05 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
let userSelection = document.getElementsByClassName('not');
let userSelectionUnread = document.getElementsByClassName('unread');
let userSelectionDot = document.getElementsByClassName('doti');
let allRead = document.getElementById("read");
let counter = document.getElementById("count");
counter.innerHTML = userSelectionUnread.length;
for(let i = 0; i < userSelection.length; i++) {
userSelection[i].addEventListener("click", function() {
userSelection[i].classList.forEach(cls => {
if(cls == "unread")
counter.innerHTML = userSelectionUnread.length - 1;
});
console.log("Clicked index: " + i);
userSelection[i].classList.remove("unread");
userSelectionDot[i].classList.remove("dot");
})
}
allRead.addEventListener("click", function(){
for(let i = 0; i < userSelection.length; i++) {
counter.innerHTML = userSelectionUnread.length;
console.log("Clicked index: " + i);
userSelection[i].classList.remove("unread");
userSelectionDot[i].classList.remove("dot");
}
})