Home > Web Front-end > JS Tutorial > body text

JavaScript Learning Journey (2)_Basic Knowledge

WBOY
Release: 2016-05-16 18:56:18
Original
780 people have browsed it

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)

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template