Activity 7

1. What does querySelectorAll() do?

2. How can you create a new HTML element in the DOM using JavaScript?

3. What does the history object in the BOM do?

4. How can you dynamically change the DOM with JavaScript?

5. What does the DOM represent in a web page?

6. How can you append a newly created element to a parent element in the DOM?

7. How can you navigate to a new page using JavaScript?

8. How do you select an element with a specific ID?

9. What does querySelector() do?

10. What is the DOM?

Correct Answers

1. What does querySelectorAll() do? ✅ Selects all elements matching a selector.

2. How can you create a new HTML element in the DOM using JavaScript? ✅ document.createElement()

3. What does the history object in the BOM do? ✅ Allows navigation through the browser history.

4. How can you dynamically change the DOM with JavaScript? ✅ Use methods like querySelector() and .style.

5. What does the DOM represent in a web page? ✅ The structure of an HTML document as an object model.

6. How can you append a newly created element to a parent element in the DOM? ✅ parentElement.appendChild(newElement)

7. How can you navigate to a new page using JavaScript? ✅ Modify the location.href property.

8. How do you select an element with a specific ID? ✅ Use #id in the selector.

9. What does querySelector() do? ✅ Selects the first element matching a selector.

10. What is the DOM? ✅ A logical tree structure for HTML documents.

Instructions:

Set Up Your Development Environment

Change Background Color Based on Device

Final Output

Change Background Color Dynamically

Resize the browser window to see the background color change.