Sitemap
Oni Samuel

Oni Samuel

Document object model

Sep 27, 2023

--

It is a programming interface that allows us to create, change, or remove elements from the document. We can also add events to these elements to make our page more dynamic.

The DOM views an HTML document as a tree of nodes. A node represents an HTML element.

How to Select Elements in the Document

Methods for selecting an element in the HTML document.

getElementById()

querySelector()

Get Oni Samuel’s stories in your inbox

Join Medium for free to get updates from this writer.

querySelectorAll()

1. getElementById()

In HTML, ids are used as unique identifiers for the HTML elements. This means you cannot have the same id name for two different elements

2. querySelector()

this method can be use to find elements with one or more CSS selectors.

3. querySelectorAll()

This method finds all of the elements that match the CSS selector and returns a list of all of those nodes.

--

--