DOM object details

Source: Internet
Author: User
Tags event listener

Overview: Dom allows you to access and modify the content and structure of a document in a language-independent way. In other words, this is a common way to represent and process an HTML or XML document. It is very important that Dom is designed based on the specification of Object Management Organization (OMG), so it can be used in any programming language.

Mode View:

I. node details

A) Element Node

Only element nodes have childnodes and only child nodes.

Nodename: Element label name nodetype: 1 nodevalue: NULL

B) attribute nodes

Nodename: property name nodetype: 2 nodevalue: Property Value

C) Text Node

Nodename: # text nodetype: 3 nodevalue: Text Content

Ii. Main Methods:

Getelementbyid ()

Get the node set according to the name attribute: getelementsbyname () can only be called by document

Get the node set by Tag Name: getelementsbytagname ()

Determine whether this element node has a subnode: haschildnodes ()

Replace one child node in a given parent element with another child node replaceChild (new, old)

Getattribute (attibutename)

Setattribute (attibutename, value)

Create an element node createelement (elementname) based on the given Tag Name)

Create a text node createtextnode () based on the given text content ()

Appendchild (node)

Insert a given node into a given element node to the front of the child node insertbefore (new, target)

Delete a subnode removechild (node) from a given element)

Iii. main attributes:

The documentelement returns the root node, that is, the HTML Tag node.

Nodename: return the node name.

Nodetype return Node Type

Nodevalue: return the value of the node.

Childnodes returns an array consisting of the Child Nodes of the given element.

Firstchild returns the first subnode of a given element node.

Lastchild: returns the last subnode of a given element node.

Nextsibling: returns the next sibling node of a given node.

Parentnode: returns the parent node of a given node.

Previussibling: returns the previous sibling node of a given node.

The innerhtml attribute can be used to read and write the HTML content of a given element.

4. Create a paging operation instance for Dom implementation

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML> 

Related Article

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.