Js traverses the attributes and methods attached to the subsections

  • 2020-03-30 03:45:24
  • OfStack


//Remove all child nodes before adding them 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 nextSibling of the current node (read only)
PreviousSibling returns the previousSibling of this node (read only)
ParentNode returns the parentNode (read only)
List of childNodes of the childNodes storage node (read only)
NodeValue returns the text of the node (read and write)
Text returns the Text content of this node and its descendants (read-write)
NodeName returns the name of the node (read only)

List of Attributes for the Attributes store node (read only)
DataType returns the dataType of this node
Definition of a node given in a DTD or XML schema (read only)
Doctype specifies document type node (read only)
DocumentElement returns the root element of the document (read and write)
FirstChild returns the firstChild of the current node (read only)
Implementation returns the XMLDOMImplementation object
LastChild returns the lastChild of the current node (read only)
NodeType returns the type of the node (read only)
NodeTypedValue store node values (read-write)
OwnerDocument returns the root document containing this node (read only)
Parsed returns whether the node and its children have been Parsed (read only)
Prefix returns the namespace Prefix (read only)
PreserveWhiteSpace specifies whether to preserveWhiteSpace (read and write)
Url returns the url of the most recently loaded XML document (read only)
Xml returns an Xml representation of the node and its descendants (read-only)

Methods:

GetElementsByTagName returns the collection of elements with the specified name
AppendChild adds a new child to the current node, after the last child
CreateElement creates an element node
CreateTextNode creates a text node that includes the given data
RemoveChild removes the specified child node from the list of children
HasChildNodes returns whether the current node has children

CloneNode returns a copy of the current node
CreateAttribute creates a new attribute
CreateCDATASection creates a CDATA segment that includes the given data
CreateComment creates a comment node
CreateDocumentFragment creates a DocumentFragment object
CreateEntityReference creates an EntityReference object
CreateNode creates a node of the given type, name, and namespace
Node createPorcessingInstruction create operation instruction
InsertBefore inserts a child node before the specified node
Load imports the XML document in the specified location
LoadXML imports the XML document for the specified string
ReplaceChild replaces the specified child node from the child node list
Save the XML file to the specified node
SelectNodes matches the specified node and returns a list of matching nodes
The selectSingleNode matches the specified node and returns the first matched node
TransformNode transforms the node and its descendants using the specified style sheet
TransformNodeToObject USES the specified style sheet to transform the node and its descendants into objects


Related articles: