Home  >  Article  >  Web Front-end  >  JavaScript Learning Journey (2)_Basic Knowledge

JavaScript Learning Journey (2)_Basic Knowledge

WBOY
WBOYOriginal
2016-05-16 18:56:18781browse

Chapter 3 DOM

DOM is the acronym for "Document Object Model".

Node

Element node: It is the atom of DOM. For example: the name of the text paragraph element p, the name of the unordered list element ul... [The attribute value of nodeType is 1]

Text node (text node): Text nodes are always included inside element nodes. [The attribute value of nodeType is 3]

Attribute node: Attribute node is always placed in the start tag. For example: title="a gentle reminder" [the attribute value of nodeType is 2]



getElementById() method returns the object



document .getElementById(id) id must be placed in single quotes or double quotes. For example: document.getElementById("purchases")



The getElementsByTagName() method returns an object array



getElementsByTagName(tag) tag must be the name of the (x)html tag and placed in double quotes, such as: document.getElementsByTagName("li")







The getAttribute() method queries attributes through a specific object call



object.getAttribute(attribute)



setAttribute() method sets attributes



object.setAttribute(attribute,value)

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