-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (32 loc) · 923 Bytes
/
script.js
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
var container=document.querySelector(".container");
var rating=0;
var clickables=document.querySelectorAll(".clickable");
var text;
var rd=document.querySelector(".ratingdisplay");
var s1=document.querySelector("#slide1");
var s2=document.querySelector("#slide2");
function toggleClicked(e){
if(e.target.className==="num clickable"){
clickables.forEach(function(i){
i.classList.remove("clicked");
})
e.target.classList.add("clicked");
rating=e.target.innerHTML;
text=document.createTextNode("You selected "+rating+" out of 5")
}
}
var creatText=()=>{
rd.append(text);
}
var toggleSlides=(e)=>{
if(e.target.className==="submit"){
s1.classList.add("disabled");
s2.classList.remove("disabled");
creatText();
}
}
function UIhandler(e){
toggleClicked(e);
toggleSlides(e);
}
container.addEventListener("click",UIhandler);