1. Access the elements in the document
Document. getelementbyid ('id'): gets the element of the given ID and uses it as an object.
Document. getelementbytagname ('tagname'): obtains all elements whose tags are named tagnames and stores them in a list similar to an array.
2. Read the attributes, node values, and other node data of the element.
Node. getattribute ('attribute'): gets the value of attribute.
Node. getattribute ('attribute'. 'value'): Set the attribute value to value.
Node. nodetype: Read node type (1 = element, 3 = text node ).
Node. nodename: Read the node name (element name or # textnode ).
Node. nodevalue: read or set the value of a node (text content in the case of a text node ).
3. operations between nodes
Node. previussibling: Get the previous sibling node and save it as a object.
Node. nextsibling: Get the next sibling node and save it as an object.
Node. childnodes: obtains all the child nodes of the object and stores them in a list. For the first and last nodes, you can also use node. firstchild and node. lastchild for short.
Node. parentnode: Get the node containing the node.
4. Create a New Node
Document. createelement (element): to create a new element named element, you must provide an element name in the string format. Document. createtextnode (string): Creates a text node with a node value of string.
Newnode = node. clonenode (bool): Create a newnode node as a node copy (clone ). If the bool value is true, this clone includes cloning of all the child nodes and attributes of the original node. Node. appendchild (newnode): Use newnode as a subnode and add it after all the subnodes of the node. Node. insertbefore (newnode, oldnode): inserts newnode before the node's child node oldnode. node. removechild (oldnode): remove the child node lodnode of the node. node. replaceChild (newnode, oldnode): replace the child node lodnode of the node with the node newnode. element.
Innerhtml: read and write the HTML content of a given element. It is a string that contains the text content of all subnodes and their attributes.