getElementById(): Gets the element in the document with the specified unique ID attribute value
getElementsByName(name): The returned is an array
getElementsByTagName(): Returns the set of element child elements with the specified tag name
getAttribute(): Returns the attribute value of the specified attribute name
document.getElementsByTagName("a")[0].getAttribute("target");setAttribute(): Add the specified attribute and assign it the specified value.
document.getElementsByTagName("INPUT")[0].setAttribute("type","button");Node properties:
Node Name (read-only):nodeName
NodeValue: nodeValue
Node Type (read-only):nodeType
Child nodes:
ele.childNodes Returns the array
firstChild
lastChild
Parent node
There is only one parentNode
Brother node
nextSibling node that follows a node
PreviousSibling
Insert node
appendChild() insert at the end
insertBefore(newnode,node) before the node node
Delete nodes
removeChild(node) successfully returns the deleted node failed to return null
Replace element nodes
replaceChild(newnode,oldnode) implements the replacement of child node objects
Create element nodes
createElement()
Create a text node
createTextNode()
Replication node
The node that needs to be copied.cloneNode(true/false)
true replicates the current node and is extremely child nodes, false only replicates the current node.
The above brief analysis of some common methods for operating DOM by JS is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.