P3.8: DOM Editing & Mutations

DOM manipulation allows JS to dynamically alter content, colors, and layout nodes.


1. Changing Contents & Styles

const title = document.querySelector("#title");
title.textContent = "New Title!";
title.style.color = "#39FF14";

🎓 Practice Assignment Tasks

  • Add a blank div with ID `box`.
  • Write JS to inject an `

    ` tag inside it using `innerHTML`.

Stuck? Hints available
// Write your JavaScript logic here
// Click 'Run Code' to see console outputs below
🔒 Code requirements not met yet. Complete the tasks above.
🔒 Complete the Practice Assignment above to unlock completion.
Advertisement
NS
Ask Nextsem
AI Mode
NS
Home
Course
Playground