Home >Web Front-end >JS Tutorial >Example of use of remove() method in jQuery_jquery

Example of use of remove() method in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:24:371052browse

The example in this article describes the usage of the remove() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method will remove all matching elements from the DOM.

Note: The remove() method will not delete the matching elements from the jQuery object, so these matching elements can be used again in the future, but except for the element itself, other For example, bound events, additional data, etc. will be removed.

Grammar structure:

Copy code The code is as follows:
$(selector).remove(expr)

Parameter list:

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

Example 1:

Copy code The code is as follows:






remove() function-Script Home




I am first

I am second




The following code can delete the div with id first in the div collection.

Example 2:

Copy code The code is as follows:






remove() function-Script Home




I am first

I am second




If the parameter is omitted, all matching elements will be deleted.

Example 3:

Copy code The code is as follows:






remove() function-Script Home





I am first

I am second




remove() has removed the matching element in the DOM, but it has not removed it from the jquery object.

I hope this article will be helpful to everyone’s jQuery programming.

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