java script dom
java script dom
Used for DOM manipulation, event handling, animations, APIs, and more.
JavaScript Features
Lightweight – Doesn't require compilation.
let x = 10, y = 5;
console.log("Number:", i);
}
Functions in JavaScript
Functions help organize code into reusable blocks.
function greet(name) {
console.log(greet("Alice"));
Arrays & Objects
Arrays: Store multiple values.
document.body.appendChild(newPara);
Handling Events in JavaScript
JavaScript can handle user actions like clicks.
document.getElementById("btn").addEventListener("click", function() {
alert("Button clicked!");
});
Simple Counter Example
let count = 0;
document.getElementById("increase").addEventListener("click", () => {
count++;
document.getElementById("counter").textContent = count;
});