Activity 7
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
- Open your preferred code editor (e.g., VS Code, Sublime Text, or Notepad++).
- Create a new file and save it with the
.htmlextension (e.g., Activity4.html).
Change Background Color Based on Device
- Use JavaScript to detect the screen.
- Apply different background colors.
- Update the background color dynamically when resizing the browser window.
Final Output
- ✅ A webpage that changes its background color based on screen device.
- ✅ The background should update dynamically as the window resizes.
- ✅ Works on different screen sizes like mobile, tablet, and desktop.