-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
28 lines (20 loc) · 833 Bytes
/
scripts.js
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
// Change Background Color
const changeColorButton = document.getElementById("changeColor");
const colorPicker = document.getElementById("colorPicker");
function changeBackgroundColor() {
document.body.style.backgroundColor = colorPicker.value;
}
changeColorButton.addEventListener("click", changeBackgroundColor);
// Live Text Update
const textChanger = document.getElementById("textChanger");
const output = document.getElementById("output");
function updateText(event) {
output.textContent = event.target.value || "Your text will appear here.";
}
textChanger.addEventListener("input", updateText);
// Alert Function
const showAlertButton = document.getElementById("showAlert");
function showAlert() {
alert("Hello! Thanks for visiting the playground.");
}
showAlertButton.addEventListener("click", showAlert);