Document Object Model (DOM) is a standard programming interface recommended by the W3C organization for processing extensible markup languages. On a web page, the objects that organize the page (or document) are organized in a tree structure, and the standard model used to represent the objects in the document is called DOM. This article mainly shares with you how to obtain DOM elements in js.
Get by ID (getElementById)
By name attribute (getElementsByName)
By class name (getElementsByClassName)
By tag name (getElementsByTagName)
Get html (document.documentElement)
Get body (document.body)
Get a single element through the selector (querySelector)
Get a single element through the selector Group element (querySelectorAll)
Related recommendations:
Sharing of DOM knowledge points in js
In-depth DOM application of JavaScript
The above is the detailed content of How to get DOM elements in js. For more information, please follow other related articles on the PHP Chinese website!