五、节点克隆

//添加点击事件
$("#test").on("click",function(){
$(this).css("background-color","greenyellow");
})

1.clone()

//注意:克隆的东西只能用一次

//仅复制结构,事件丢失
var test2 = $("#test").clone();
$("body").append(test2);

2.clone(true)

//结构,事件都复制
var test3 = $("#test").clone(true);
$("body").append(test3);

猜你喜欢

转载自www.cnblogs.com/myz666/p/9003927.html