Clone node clone() of jQuery

  • The cloned element only exists in the memory, if it needs to be displayed on the page, it must be appended to the page
  • The clone() method parameter will be cloned to the descendant node whether it is true or false
  • If the parameter of the clone() method is true: it means that the event will be cloned together; if it is false, the event will not be cloned, and the default parameter is false
var div = $("#div").clone()
// 修改克隆节点的id
div.attr('id', 'id1')
// 从内存追加到页面上
$('body').append(div)

Guess you like

Origin blog.csdn.net/qq_52421092/article/details/131253474