Dom cloning operation (deep clone/Shallow clone)

Source: Internet
Author: User

Deep clones (the text node within the clone element plus all the descendants element nodes),

Shallow Clone (clone the element itself, do not clone the text node and the Descendants node),

1. CloneNode () accepts a parameter with an optional value of TRUE or false. True represents the clone element and all its child nodes. False indicates that the cloned element does not contain its child nodes. Usually, we use true in practice, and I have never encountered a situation where I want to clone a node without its child nodes.

2. CloneNode () does not clone an event handler. So every time you clone a node, you have to redefine the event handler on the clone. When IE uses attachevent to bind events to DOM elements, the events are copied over after CloneNode. And the events added with AddEventListener will not.

Dom cloning operation (deep clone/Shallow clone)

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.