This page demonstrates basic JavaScript concepts by changing HTML and CSS dynamically.
Open your browser console (Right Click → Inspect → Console) to try some snippets directly.
This text will be changed.
document.getElementById("text-demo").textContent = "Text changed with JS!";
document.getElementById("color-box").style.backgroundColor = "lightblue";
You can hide or show me.
const p = document.getElementById("toggle-paragraph");
p.classList.toggle("hidden");
document.getElementById("alert-button").addEventListener("click", () => {
alert("You clicked me!");
});
const randomColor = "#" + Math.floor(Math.random()*16777215).toString(16);
document.getElementById("random-color-box").style.backgroundColor = randomColor;
const ul = document.querySelector("#list-area ul");
const li = document.createElement("li");
li.textContent = "New item added!";
ul.appendChild(li);