Home  >  Article  >  Web Front-end  >  jQuery的remove()方法使用详解_jquery

jQuery的remove()方法使用详解_jquery

WBOY
WBOYOriginal
2016-05-16 15:46:011453browse

remove()方法的定义和用法:

此方法将会从DOM中删除所有匹配的元素。

说明:remove()方法不会把匹配的元素从jQuery对象中删除,因而可以在将来再使用这些匹配的元素,不过除了这个元素本身得以保留之外,其他的比如绑定的事件,附加的数据等都会被移除。

语法结构:

$(selector).remove(expr)

参数列表:

参数 描述
expr 可选。用于筛选元素的jQuery表达式

实例代码:






 

我是第一
我是第二

以下代码能够删除div集合中id为first的div。






 

我是第一
我是第二

如果省略参数,那就是删除所有匹配的元素。







 

我是第一
我是第二

remove()已经将DOM中的匹配元素删除,但是并没有将它从jquery对象中删除。

jquery使用remove()方法删除指定class子元素的方法







This is a paragraph in the div.

This is another paragraph in the div.

This is another paragraph in the div.

看到这段代码之后,我想不用我过多的解释了。大家就明白了吧,很有意思的方法。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn