-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (41 loc) · 1.28 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Write your code here
// fetch()
// .then(res => res.json())
// .then(data => console.log(data))
document.getElementById("mybtn").addEventListener("click",function()
{
var mybox=document.getElementById("Resturant Menu");
if(mybox.style.display=="none")
{
mybox .style.display="block";
}
else
{
mybox.style.display="none"
}
})
function myFunction() {
var x = document.createElement("FORM");
var t = document.createTextNode("Click me");
x.appendChild(t);
document.body.appendChild(x);
alert("Please wait for 20 minutes")
}
const star = document.querySelector(".stars a")
const stars = document.querySelectorAll(".stars a")
stars.forEach((star, clickedIdx) => {
star.addEventListener("click", () => {
star.classList.add("disabled")
stars.forEach((otherStar, otherIdx) => {
if (otherIdx <= clickedIdx){
otherStar.classList.add("active")
}
})
console.log(`star of index ${idx +1} was clicked`);
})
})
const myform = document.getElementById("myform")
myform.addEventListener("submit", (e) => {
e.preventDefault()
console.log("form has been submitted")
})