16.3 DOM Manipulation (20 mins)
let heading = document.getElementById("title"); heading.innerText = "New Heading Text"; // Changes the text inside the <h1>
let image = document.getElementById("myImage"); image.setAttribute("src", "new_image.jpg"); // Changes the image source
let paragraph = document.getElementById("description"); paragraph.style.color = "blue"; // Changes the text color to blue paragraph.style.fontSize = "20px"; // Changes the font size to 20px
let message = document.getElementById("welcomeMessage"); message.innerText = "Welcome, User!"; // Changes the text content
let link = document.getElementById("externalLink"); link.setAttribute("href", "https://www.example.com"); // Changes the link's destination
let button = document.getElementById("myButton"); button.style.backgroundColor = "green"; // Changes the button background color button.style.padding = "10px"; // Changes button padding
Student Activity (20 mins):
Step-by-Step Activity:
Explanation of the Code:
Challenge:
Key Changes:
Activity Follow-up Questions:
Expected Outcome:
Last updated