The attachment and method _javascript technique of JS Traversal sub-node idea element

Source: Internet
Author: User
Tags readable

Copy Code code as follows:

Remove all child nodes before adding child nodes

var Usernameele = document.getElementById ("username");
var childs = Usernameele.childnodes;
for (var i = childs.length-1 i >= 0; i--) {
Usernameele.removechild (Childs[i]);
}
var username = document.createTextNode (obj.username);
Usernameele.appendchild (username);

Property:

NextSibling returns the next sibling node of the current node (read-only)
PreviousSibling returns the previous sibling node of this node (read-only)
ParentNode Return parent node (read only)
ChildNodes List of child nodes for storage nodes (read-only)
NodeValue returns the text of the node (readable and writable)
Text returns the textual content of this node and its descendants (readable and writable)
NodeName returns the name of the node (read-only)

Attributes a list of properties for storage nodes (read-only)
DataType returns the data type of this node
Definition of a node given in a DTD or XML schema (read-only)
Doctype Specify document Type node (read-only)
DocumentElement returns the root element of the document (Readable and writable)
FirstChild returns the first child node of the current node (read-only)
Implementation return Xmldomimplementation Object
LastChild returns the last child node of the current node (read-only)
NodeType returns the type of the node (read-only)
nodeTypedValue Storage node value (readable and writable)
Ownerdocument returns the root document containing this node (read-only)
Parsed returns whether this node and its child nodes have been resolved (read-only)
Prefix return namespace prefix (read only)
PRESERVEWHITESPACE Specifies whether to leave blank (read-write)
URL returns the URL of the most recently loaded XML document (read-only)
XML representation of the XML return node and its descendants (read-only)

Method:

getElementsByTagName returns the collection of elements of the specified name
AppendChild adds a new child node to the current node and places it after the last child node
CreateElement Create an element node
createTextNode Create a text node that includes a given data
RemoveChild deletes the specified child node from the list of child nodes
HasChildNodes returns whether the current node has child nodes

CloneNode Returns the copy of the current node
CreateAttribute Create a new property
Createcdatasection Create a CDATA segment that includes the given data
Createcomment create a comment node
Createdocumentfragment Create DocumentFragment object
Createentityreference Create EntityReference object
CreateNode Create a given type , the node of the name and namespace
createporcessinginstruction create an operation instruction node
InsertBefore Insert a child node before the specified node
Load Import XML document at the specified location
Loadxml Imports the XML document for the specified string
ReplaceChild replaces the specified child node from the list of child nodes
Save saves the XML file to the specified node
SelectNodes matches the node, and returns a list of matching nodes
selectSingleNode the specified match to the node and returns the first matching node
Transformnode to convert the node and its descendants using the specified style sheet
transformNodeToObject Converts a node and its descendants to an object using the specified style sheet

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.