JS DOM Object

Source: Internet
Author: User

First, the definition

    • HTML Document Object Model
    • HTML DOM defines a standard way to access and manipulate HTML documents
    • HTML DOM renders an HTML document as a tree structure with elements, attributes, and Text (node tree)

Second, Dom tree

The DOM tree is drawn to show the relationships between the objects in the document and to navigate the objects.

Third, DOM node

Each component in an HTML document is a node.

This is what the DOM provides:
The entire document is a document node
Each HTML tag is an element node
Text that is contained in an HTML element is a text node
Each HTML attribute is an attribute node

Among them, document and element node is the focus.

Iv. Relationship of nodes

Nodes in the node tree have hierarchical relationships with each other.
Terms such as the parent, Son (Child), and fellow (sibling) are used to describe these relationships. The parent node has child nodes. Child nodes of a sibling are called siblings (brothers or sisters).

    • In the node tree, the top node is called root (root)
    • Each node has a parent node, except for the root (it has no parent node)
    • A node can have any number of sub-
    • A sibling is a node that has the same parent node

The following image shows part of the node tree and the relationship between nodes:



accessing HTML elements (nodes), accessing HTML elements is equivalent to accessing nodes, and we are able to access HTML elements in different ways.

V. Node Lookup

To find a node directly:

document.getElementById ("Idname") document.getelementsbytagname ("TagName") document.getelementsbyname ("name") Document.getelementsbyclassname ("name")

Navigate to find:

'parentelement           //parent node tag element children//                All child tags firstelementchild       //First child tag element lastelementchild        // Last child tag element nextelementtsibling     //Next sibling tag element previouselementsibling  //previous sibling tag element '

JS DOM Object

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.