-
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.35 KB
/
script.js
File metadata and controls
42 lines (35 loc) · 1.35 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
"use strict";
const main = document.querySelector("main.flex-container");
const submitBtn = document.querySelector(`[type='submit']`);
const ratings = document.querySelectorAll(".ratings>button");
let value = 0;
ratings.forEach((button, index) => {
button.addEventListener("click", () => {
button.classList.toggle("btnClick");
value = index + 1;
});
});
submitBtn.addEventListener("click", () => {
const img = document.createElement("img");
const div = document.querySelector("div.flex-container");
img.setAttribute("src", "./images/illustration-thank-you.svg");
img.setAttribute("alt", "Thank you illustration");
img.style.backgroundColor = `transparent`;
div.remove();
main.appendChild(img);
const paragraph = document.createElement("p");
paragraph.innerHTML = `You selected ${value} out of 5`;
paragraph.classList.add("paragraph");
main.appendChild(paragraph);
const h1 = document.createElement("h1");
h1.innerHTML = `Thank You!`;
h1.style.fontSize = `1.8rem`;
main.appendChild(h1);
const descPara = document.createElement("p");
descPara.innerHTML = `We appreciate you taking the time to give a rating.
If you ever need more support, don't hesitate to
get in touch!`;
descPara.style.textAlign = `center`;
descPara.style.fontSize = `1.35rem`;
main.appendChild(descPara);
});