[Javascript] DOM summary, javascriptdom

Source: Internet
Author: User
Tags uppercase letter

[Javascript] DOM summary, javascriptdom

The Document Object Model of DOM (Document ObjectModel) describes the number of hierarchical nodes. D (document) is a webpage document, O (object) is a window object, and so on. Its Attributes and methods can be called. M (model) is the tree structure of the webpage document. DOM defines the objects and attributes of HTML elements and the methods for accessing them. That is, DOM can obtain, modify, add, and delete HTML elements.

1. DOM Node

DOM treats tags as nodes and considers webpages as node trees composed of nodes. There are five types of nodes: document nodes, element nodes, text nodes, attribute nodes, annotations, and nodes. Each HTML element is an element node, the text in the HTML element is a text node, each HTML attribute is an attribute node, and the comment is a comment node, these concepts are easy to understand.

1) node attributes

DOM nodes have several useful attributes: nodeName, nodetype, and nodeValue.

The nodeName attribute specifies the node name, which always contains the uppercase letter Tag Name of the HTML element; the nodeValue attribute specifies the node value; The nodeType attribute returns the node type, and the nodeType is read-only.

2) Hierarchical node attributes

The hierarchy of nodes can be divided into Parent nodes, child nodes, and sibling nodes. When an element node is obtained, you can use the hierarchical node attribute to obtain other hierarchical nodes.

2. node methods for convenient operations, W3C provides some attributes and methods for locating nodes. You can create, search, and delete nodes using their DOM:

These methods make operations on Webpage elements more convenient.

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.