JS Traversal sub-node idea element __js

Source: Internet
Author: User
Tags readable

JS Traversal sub-node idea element

The element attribute method of Js node idea

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);

Properties: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 Storage node's list of properties (read-only) DataType returns the data type definition of this node defined (read-only) for the node given in the DTD or XML Schema Doctype specifies the document type node (read-only) Docume Ntelement returns the root element of the document (readable and writable) FirstChild returns the first child node of the current node (read-only) Implementation returns Xmldomimplementation object LastChild returns when The last child node of the previous node (read-only) NodeType the type of the return node (read-only) nodeTypedValue storage node value (readable and writable) ownerdocument returns the root document containing this node (read-only) parsed returns this node and its Whether the child node has been resolved (read-only) Prefix returns the namespace prefix (read-only) preservewhitespace specifies whether to leave a blank (writable) URL returns the URL of the most recently loaded XML document (read-only) XML return node and its descendants XML representation (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 a given data createcomment create a comment node creat Edocumentfragment Create DocumentFragment Object createentityreference Create EntityReference object CreateNode Create a node of a given type, name, and namespace Createporcessinginstruction Create an action instruction node insertbefore insert a child node before the specified node Load import XML document at the specified location loadxml import the XML document for the specified string repl Acechild replaces the specified child node from the list of child nodes save the XML file to a specified node selectnodes a specified match to the node and returns a matching node list selectSingleNode a specified match to the node, and return Back to the first matching node transformnode the node and its descendants using the specified style sheet transformNodeToObject convert the node and its descendants to objects using the specified style sheet

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.