Home >Web Front-end >JS Tutorial >How to get DOM elements in js

How to get DOM elements in js

小云云
小云云Original
2018-03-15 15:55:112102browse

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

Some summary of using DOM

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn