<>DOM operation

<> One , visit / Get node

document.getElementById(id);// Return to have specified id The first object of

document.getElementsByName(name);// Returns a collection of nodes with the specified name

document.getElementsByTagName(tagname); // Returns a collection of objects with the specified label name

document.getElementsByClassName(classname); // Return with specified class Object collection for name



<> Two , Create node / attribute

* document.createElement() // Create a node
* document.createTextNode() // Create text node
* document.createAttribute() // Create an attribute on a node
<> Three , Add node

* document.inseretBefore(nextNode,referenceNode) // Insert a node before a node
* parentNode.appendChild(newNode) // Add children to a node
<> Four , Replication node

* cloneNode(true/false) // Copy a node
<> Five , Replace node

* replaceChild() // Replace a child node in a given element with another node
<> Six , Delete node

* removeChild(node) // Delete a child node
<> Node attribute operation

* getAttribute(name) // Get the value of a node attribute by attribute name
* setAttribute(name,value) // Modify the value of a node property
* removeAttribute(name) // Delete a property
<> Access relationship acquisition

<> Find child nodes

.firstChild // Get the first child node
.firstElementChild // Get the first element node
.lastChild // Get the last child node
.lastElementChild // Get the last element node
.childNodes // Get all children of a node

<> Get adjacent nodes

.previousSibling Get the adjacent previous node of a known node
.nextSibling Get the next node of a known node

<> Get parent node

.parentNode // Get the parent of a known node

<> Replace node

.replace( newNode,oldNode) Replace the old node with the new one from the parent node

<> Modify text node

* appendData(data): Add node after text node
* insertData(start,data): stay start Insert character at ,start The start value of is 0
* replaceData(start,length,data): stay start Local use data replace length Characters
* deleteData(start,length): from start Delete at length character

©2019-2020 Toolsou All rights reserved,
[RK3399][Android7.1] Learning notes DRM Driver development ( introduce )Map judge key Corresponding value Does the value exist -containsKey() Online troubleshooting HTTP Status code ——415 and 406 Science fiction comes true !“ Trisomy ” Found out exercises 11-5 Output string at specified position Shortest path Dijkstra (Python3)ElementUI In the select Of label value Forbes China Auto rich list : He xiaopengdi 11 Li Xiangdi 14 Li Bindi 15415 Status code to background error ( Essence )2020 year 7 month 15 day Wechat applet import and include difference