5. Node Cloning

//add click event
$("#test").on("click",function(){
$(this).css("background-color","greenyellow");
})

 

1.clone()

//Note: cloned things can only be used once

//Only copy the structure, events are lost
var test2 = $("#test").clone();
$("body").append(test2);

 

2.clone(true)

// structure, events are copied
var test3 = $("#test").clone(true);
$("body").append(test3);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325629856&siteId=291194637