JSLite - delete node


If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!

empty

Remove all dom child nodes from all matching node object sets, excluding itself, and clear the content.

$("#box").empty()
//⇒ self <div id="box" class="boxOne box2 box3" ></div>

remove

Delete all matching node objects [self] and all contents in [self].

$("#box").remove()
//⇒ self <div id="box" class="boxOne box2 box3" ></div>

detach !

Abandoned method (not recommended), the function is the same as remove, all bound events, additional data, etc. will be retained.

$("#box").click(function(){
    console.log("wcj")
})
var a = $("#box").detach();//删除的对象赋给a
$("body").append(a)//将a添加到 body 中还是可以点击