-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (35 loc) · 1.09 KB
/
Copy pathscript.js
File metadata and controls
42 lines (35 loc) · 1.09 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
const hearts = document.querySelectorAll(".heart i");
const btn = document.querySelector("button");
var feedback = 0;
hearts.forEach(heart => {
heart.addEventListener("mouseenter", (e)=> {
let actID = Number(e.target.id);
for (let i = 0; i < hearts.length; i++){
hearts[i].style.color = "#998ba1";
}
for (let i = 0; i <= actID - 1; i++){
hearts[i].style.color = "red";
}
});
heart.addEventListener("click", (e)=> {
// for (let i = 0; i <= Number(e.target.id) - 1; i++){
// hearts[i].style.color = "red";
// }
// removeActive();
// heart.classList.add("active");
feedback = e.target.id;
});
});
// function removeActive() {
// hearts.forEach(heart => heart.classList.remove("active"));
// };
btn.addEventListener("click", ()=> {
if (feedback == 0){
document.querySelector(".att").style.opacity = "1";
}
else{
document.querySelector(".container").innerHTML = `
<h1 style="margin: 2rem 0">Thanks for your ${feedback}/5 rating</h1>
`
}
})