Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ <h3 class = "subtitle">You've clicked the lights 0 times</h3>
</div>
<!--Connect your script here-->


<script src="script.js"></script>
</body>
</html>
28 changes: 27 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
// Write your code here
// Write your code here
let lightbulb1 = document.querySelector("#lightbulb1");
let lightbulb2 = document.querySelector("#lightbulb2");
let lightbulb3 = document.querySelector("#lightbulb3");
let subtitle = document.querySelector(".subtitle");
count = 0;

lightbulb1.addEventListener("click", function(event) {
count++;
subtitle.innerHTML = `You've clicked the lights ${count} times`;
this.classList.toggle('active');
return count;
})

lightbulb2.addEventListener("click", function(event) {
count++;
subtitle.innerHTML = `You've clicked the lights ${count} times`;
this.classList.toggle('active');
return count;
})

lightbulb3.addEventListener("click", function(event) {
count++;
subtitle.innerHTML = `You've clicked the lights ${count} times`;
this.classList.toggle('active');
return count;
})