### 7.1.1. What is DOM?
(c) The DOM represents the structure of a web page as a hierarchical tree of nodes.
(b) A generic term representing any object in the DOM tree, including element nodes, text nodes, and more.
(c) createElement and appendChild
(c) An Element Node represents the fundamental building blocks of an HTML document.
// Write code to remove the second paragraph
const p = document.getElementById('para2');
p.remove();
// Write code add a new list item with text "Mango" to the existing list of fruits at the end
const n = document.createElement('li');
n.textContent = 'Mango';
const f = document.getElementById('fruits');
f.appendChild(n)
// Write code to change the text in the second paragraph to "Hello"
document.getElementById('para2').textContent = 'Hello'
// Write code to select the second paragraph element by ID
const p2 = document.getElementById('para2');
// Add a CSS class called myStyle dynamically to that element's classList
p2.classList.add('myStyle')
// Write code to select the third paragraph element by ID
const p3 = document.getElementById('para3');
// Using inline styles set the text color to red and background color to yellow
p3.style.color='red';
p3.style.background='yellow';
// Write code to select the second paragraph element by ID
const p2 = document.getElementById('para2');
// Write code to select the button called "Click Me" by ID
const btn = document.getElementById('clickMe')
// Add an event listener to the "Click Me" button, which when clicked changes the text color of the second paragraph to red
btn.addEventListener('click', function() {
p2.style.color = 'red';
})
const styleElement = document.createElement('style');
styleElement.innerHTML = '.myStyle { color: green; }';
document.head.appendChild(styleElement);
const element = document.getElementById('para2');
element.classList.add('myStyle');
// Write code to select the second paragraph element by ID
p2 = document.getElementById('para2');
// Write code to select the third paragraph element by ID
p3 = document.getElementById('para3');
// Add a double click event listener to second paragraph which changes
// the text color of third paragraph to blue when we double click
// on the second paragraph
p2.addEventListener('dblclick',function() {
p3.style.color='blue'
})