The DOM is a tree of nodes/elements created by the browser. The top object is the document which is on the window object the browser itself. The nodes/elements represent the elements in the HTML files. Elements in the HTML file such as head, title, body, h1,
Here are some examples of examining document types.
Here are some examples of getting element by ID.
var header = document.getElementById(‘header-title’)
After setting the variable into memory you are able to change elements by using the value you gave as the element before the dot operator. I used header-title as an example. So all you would need to do is headerTitle.textContent = ‘Hello’; This would automatically update the text content with whatever you set the input. This is such an easy and powerful method to change things in the DOM.
Another use case would be getting elements by class name. Here are some example use cases.
var items = document.getElementByClassName(‘list-group-item’);
items.textcontent = ‘Hello World’;
The variable was set into memory in the first line then called by console.logging then you can easily change elements afterward. This is a recurring theme with what I’ve seen so far researching into the DOM. This method is also used for getting element by tag name. The querySelector() method returns the first element that matches a specified CSS selector(s) in the document.