?
This document uses PHP Chinese website manual Release
從DOM中刪除所有匹配的元素。
這個(gè)方法不會(huì)把匹配的元素從jQuery對(duì)象中刪除,因而可以在將來(lái)再使用這些匹配的元素。與remove()不同的是,所有綁定的事件、附加的數(shù)據(jù)等都會(huì)保留下來(lái)。
用于篩選元素的jQuery表達(dá)式
從DOM中把所有段落刪除
<p>Hello</p> how are <p>you?</p>
$("p").detach();
how are
從DOM中把帶有hello類的段落刪除
<p class="hello">Hello</p> how are <p>you?</p>
$("p").detach(".hello");
how are <p>you?</p>