TGViewer
Web Development Web Development @webdevcoursefree · 79.7K subscribers
Post #3400 4.39K
✅ JavaScript Fundamentals Part:2 – DOM, Events Basic Animation 🎨🖱️

1️⃣ What is the DOM?
The DOM (Document Object Model) represents your HTML page as a tree of objects. JavaScript can read/change it to make your page dynamic.

Example – Change text of an element:
document.getElementById("title").innerText = "Hello, World!";

▶️ You can select elements by ID, class, tag, etc.

2️⃣ Event Handling – Making Web Pages Interactive
Add actions when users click, hover, type, etc.

document.getElementById("btn").addEventListener("click", function() {
alert("Button clicked!");
});

▶️ Events include click, mouseover, keydown, submit, etc.

3️⃣ Changing Styles with JavaScript

document.getElementById("box").style.backgroundColor = "blue";

▶️ Use .style to dynamically change CSS.

4️⃣ Basic Animation with setInterval

let pos = 0;
let box = document.getElementById("box");

let move = setInterval(() => {
if (pos >= 200) clearInterval(move);
else {
pos += 5;
box.style.left = pos + "px";
}
}, 50);

▶️ Moves a box 200px to the right in steps.

🎯 Practice Tasks:
• Create a button that changes background color on click
• Make a div move across the screen using setInterval
• Show a message when user hovers over an image

You can find the solution here: https://whatsapp.com/channel/0029Vax4TBY9Bb62pAS3mX32/554

💬 Tap ❤️ for more!
  • ❤ 6
  • 👍 1
More from @webdevcoursefree
  1. Oct 16, 2026🌐 Web Development Roadmap — Part 18 HTML Lists Lists are used whenever information needs…
  2. Oct 14, 2026🌐 Web Development Roadmap — Part 17 HTML Images — <img> Tag Images make webpages more vis…
  3. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
  4. Oct 12, 2026For example: Go to Profile → <a> Submit Form → <button> Open Article → <a> Delete Account…
  5. Oct 12, 2026🌐 Web Development Roadmap — Part 16 HTML Links — Tag Links are one of the most important…
  6. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →