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>