-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (19 loc) · 924 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (19 loc) · 924 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
// This line finds the h1 element on the page and stores it in a variable.
const heading = document.querySelector('h1');
// This line changes the text content of that stored element.
heading.textContent = 'My Interactive Coding Journey';
// Find the button and the body elements on the page
const colorButton = document.querySelector('#color-btn');
const body = document.querySelector('body');
// Add an event listener to the button that waits for a 'click'
colorButton.addEventListener('click', () => {
// This is the code that runs ONLY when the button is clicked
body.style.backgroundColor = '#e0f7fa'; // A nice light cyan color
// Select the new theme button
const themeButton = document.querySelector('#theme-btn');
// Add a click listener for the theme button
themeButton.addEventListener('click', () => {
// Toggle the .dark-mode class on the body element
body.classList.toggle('dark-mode');
});
});