DOM node depth cloning function CloneNode () instance _javascript technique

Source: Internet
Author: User

This article describes the DOM node depth cloning function clonenode () usage. Share to everyone for your reference.

The implementation methods are as follows:

Copy Code code as follows:
<script type= "Text/javascript" >
function T () {
var Nodeul = document.getelementsbytagname (' ul ') [0];//get the UL node that needs to be replicated
var Newul = Nodeul.clonenode (true);//true represents deep copying, that is, the Li and the text along the edge; if False, copy only UL

var node_copy = document.getElementById (' Copyul ');
Node_copy.appendchild (Newul);
<div id= "Container" >
<li> Spring </li>
<li> Summer </li>
<li> Autumn </li>
<li> Winter </li>
<div id= "Copyul" >
<button onclick= "t ()" value= "" > Specify Location Add node </button>

I hope this article will help you with your JavaScript programming.

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: 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.