From a77d1cc71622ce511b6e70cd9efd357f50483317 Mon Sep 17 00:00:00 2001 From: Christopher Rodriguez Date: Thu, 7 Mar 2024 14:06:19 -0500 Subject: [PATCH] completed lightbulb tasks --- index.html | 2 +- script.js | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 53b6a34..77262e5 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,6 @@

You've clicked the lights 0 times

- + \ No newline at end of file diff --git a/script.js b/script.js index 7056c69..b67f1ad 100644 --- a/script.js +++ b/script.js @@ -1 +1,27 @@ -// Write your code here \ No newline at end of file +// 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; +}) \ No newline at end of file