首頁  >  文檔處理  > remove([expr])

返回值:jQueryremove([expr])

jQuery remove() 方法概述

從DOM中刪除所有匹配的元素。

這個方法不會把匹配的元素從jQuery對象中刪除,因而可以在將來再使用這些匹配的元素。但除了這個元素本身得以保留之外,其他的比如綁定的事件,附加的數(shù)據(jù)等都會被移除。

參數(shù)

exprStringV1.0

用于篩選元素的jQuery表達式

示例

描述:

從DOM中把所有段落刪除

HTML 代碼:
<p>Hello</p> how are <p>you?</p>
jQuery 代碼:
$("p").remove();
結果:
how are

描述:

從DOM中把帶有hello類的段落刪除

HTML 代碼:
<p class="hello">Hello</p> how are <p>you?</p>
jQuery 代碼:
$("p").remove(".hello");
結果:
how are <p>you?</p>