Use JS to complete the operation of node additions, modifications, etc.

Source: Internet
Author: User

  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> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.