Property:
1. NodeName
Node name, equivalent to TagName. Property node returns the property name, and the text node returns #text. NodeName, is read-only.
2. NodeType
Value: 1, Element node, 2, Attribute node, 3, text node. NodeType is read-only.
3. NodeValue
Returns a string that indicates the value of this node. The element node returns NULL, the property node returns the property value, and the text node returns the text. NodeValue can be read-writable, which is not writable on element nodes. is typically used only to set the value of a text node.
4. ChildNodes
Returns an array of child nodes. The childnodes of the text and attribute nodes is always null. You can use HasChildNodes () to determine whether there are child nodes. Read-only property, to remove add nodes can not operate ChildNodes array method uh.
5. FirstChild
Returns the first child node. The text and attribute nodes do not have child nodes and return an empty array, which is special treatment for these two-bit. For element nodes, NULL is returned if there are no child nodes. There is an equivalent: Firstchild=childnodes[0].
6. LastChild
Returns the last child node. return value with FirstChild, three-party treatment reference above. There is an equivalence: lastchide=childnodes[childnodes.length-1].
7. nextSibling ()
Returns the next sibling node of the node. Returns null if there is no next sibling node. Read-only property, you cannot change the application.
8. PreviousSibling ()
Returns the previous sibling node of a node. Ditto.
9. parentnode ()
Returns the parent node of a node. Document.parentnode () returns null, and in other cases returns an element node, because only the element node has child nodes, and any node outside the document has a parent node. ParentNode (), is also a read-only guy.
Operation:
1. Create a Node
createelement (' TagName ');
such as: Var op=document.createelement (' P '); created a <p></p> tag.
2. Create a text node
createTextNode (' text ');
such as: Var Otext=document.createtextnode (' is a paragh! ');
3. Additional child nodes
AppendChild (o), where O is the node object.
For example: Document.body.appendChildNode (o); append at the end of the body
Document.forms[0].appendchildnode (o); Append at end of form form
Op.appendchildnode (o); append to the end of the element, whose total OP is the node object.
4. Create a document fragment
Createdocumentfragment ();
such as: Var of=document.createdocumentfragment ();
5. Delete node
RemoveChild (OP);
such as: Document.body.removeChild (OP), remove the OP node object from the body.
6. Replacement node
Replacechid (newop,targetop); Replace the target node targetop with NEWOP
such as: Document.body.replayChild (OPA,OPB). PS: How could it be so special? The source and target operands are all parameters, why is the caller a document.body? Remember first, don't worry. --The replaced must be a child of the body, which can replace the document.body with other element, as long as it is replaced by the child node of the element.
7. Insert Node
Insertbefor (Newop,targetop);
InsertAfter (Newop,targetop);
8. Set or get attribute node
setattribute (' key ', ' value ');
GetAttribute (' key ', ' value ')
9. Copy nodes.
CloneNode (True/false)