jQuery API | 返回首页目录 | jQuery API 中英文对照版 |
remove(expr) |
remove(expr)
从DOM中删除所有匹配的元素。 这个方法不会把匹配的元素从jQuery对象中删除,因而可以在将来再使用这些匹配的元素。 可以通过一个可选的表达式对要删除的元素进行筛选。 返回值:jQuery 参数:
示例: $("p").remove(); HTML 代码: <p>Hello</p> how are <p>you?</p> 结果: how are 示例:$("p").remove(".hello"); HTML 代码: <p class="hello">Hello</p> how are <p>you?</p> 结果: how are <p>you?</p> Removes all matched elements from the DOM. This does NOT remove them from the jQuery object, allowing you to use the matched elements further. Can be filtered with an optional expressions. Return value: jQuery
Example: $("p").remove(); Before: <p>Hello</p> how are <p>you?</p>Result: how are Example: $("p").remove(".hello");Before: <p class="hello">Hello</p> how are <p>you?</p>Result: how are <p>you?</p> |