This article for everyone in detail under the use of JS to complete the node of the deletion and modification of the operation, and so on, the specific implementation of the following, interested friends can refer to the following
Requirements: Completion of node additions and deletions copy operations methods and attributes: 1. Gets the parent node of a node ParentNode property 2. Gets the set of child nodes for a node ChildNodes Properties 3. Create a key a new node createtextnode (node text content) The method of the Document object is not very well compatible with some browsers createelement (object) Methods for document objects such as: Document.createelement ("a"); 4. Add attributes and property values setattribute (attributes, property values) to a node object; For example: Anode.setattribute ("href", "http://www.baidu.com"); 5. Replace the child nodes under one node ReplaceChild (new node, atomic node); 6. Add a node under a node appendchild (node to add) 7. Clone a node CloneNode () without passing the parameter and passing in the true parameter, the clone node includes the child node The code is as follows: <! DOCTYPE html>