-
- document.createElement (); you need to pass in a tag name as a parameter. You will create a corresponding node according to the tag name and return the node. document.createTextNode (); you need to pass in a text content as the parameter appendChild ()
Usage: parent element.appendChild( child node ).
A child of a node can be inserted before the new node
Usage: Parent node. insertBefore( new node, old node );
Replacechild(); replace child node
Usage: parent.replaceChild( new node, old node );
Removechild(); can delete a child node
Usage: parent.removeChild(child node).
InnerHTML can also be used to add dom. Generally, the two methods are combined.
e.g. city.innerHTML += " <li>GuangZhou</li> ";
Confirm (“); a prompt box with confirm and Cancel buttons will pop up. If the user clicks confirm, it will return true; otherwise, it will return false </ OL>