From 58a8d669922d5016e504aadda570b923d03f809b Mon Sep 17 00:00:00 2001 From: adityalaxkar Date: Sat, 24 Aug 2024 08:45:45 +0530 Subject: [PATCH] Add files via upload --- project1/indexc.html | 97 ++++++++++++++++++++++++++++++++++++++++++++ project1/script.js | 22 ++++++++++ 2 files changed, 119 insertions(+) create mode 100644 project1/indexc.html create mode 100644 project1/script.js diff --git a/project1/indexc.html b/project1/indexc.html new file mode 100644 index 0000000..b790dde --- /dev/null +++ b/project1/indexc.html @@ -0,0 +1,97 @@ + + + + + + color Scheme Switcher + + + + + +
+ +

Color Scheme Switcher

+
+
+
+
+
+
+

Try on one of the above color
+
To change the background of this page
+

+
+ + + + \ No newline at end of file diff --git a/project1/script.js b/project1/script.js new file mode 100644 index 0000000..860aec2 --- /dev/null +++ b/project1/script.js @@ -0,0 +1,22 @@ +const buttons = document.querySelectorAll('.button'); +//console.log(buttons); +const body = document.querySelector('body'); +buttons.forEach(btn => { + //console.log(btn); + btn.addEventListener('click',function(e){ + console.log(e); + console.log(e.target);// to target particular element using given event + if (e.target.id === 'grey') { + body.style.backgroundColor = 'grey'; + } + else if (e.target.id === 'white') { + body.style.backgroundColor = 'white'; + } + else if (e.target.id === 'blue') { + body.style.backgroundColor = 'blue'; + } + else if (e.target.id) { + body.style.backgroundColor = 'yellow'; + } + }) +});