What is the DOM?
According to W3C, The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.
The Selectors API
In the past jQuery allowed us to select elements from the DOM in a very easy way. Since 2013 jQuery is no longer necessary thanks to the Selectors API.
The Selectors API provides methods that make it fast and easy to retrieve element nodes from the DOM. Here are a few examples:
Get Element by Id name
The selection is based on the Id name. This selector returns the first element that matches the specified CSS selector in the document.
Get Element by Class Name
The selection is based on the Class name. Returns a list of items that have a specific class name.
Get Element by Tag Name
The selection is based on the Tag name. Returns a list of items that have a specific tag name.
The method returns the first element that matches the specified CSS selector in the document. We can use all kinds of CSS selectors that we will use in a normal CSS file.
This method returns all the elements that match the specified CSS selector in the document.
Thanks for reading, if you like the article be sure to subscribe down below to be the first to know when new articles are published. Also, we are always looking to improve if you got any constructive criticism let me know.