forked from MultiverseLearningProducts/Lightbulb-Selectors
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (21 loc) · 745 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (21 loc) · 745 Bytes
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
// Write your code here
let bulb1 = document.querySelector("#lightbulb1");
let bulb2 = document.querySelector("#lightbulb2");
let bulb3 = document.querySelector("#lightbulb3");
let sub = document.querySelector(".subtitle");
let count = 0;
bulb1.addEventListener("click", function(){
count += 1;
sub.textContent = `You've clicked the light ${count} times`;
this.classList.toggle("active");
});
bulb2.addEventListener("click", function(){
count += 1;
sub.textContent = `You've clicked the light ${count} times`;
this.classList.toggle("active");
});
bulb3.addEventListener("click", function(){
count += 1;
sub.textContent = `You've clicked the light ${count} times`;
this.classList.toggle("active");
});