Basic introduction to remove in jQuery and comparison of differences between empty

巴扎黑
Release: 2017-06-25 09:37:04
Original
1369 people have browsed it

Definition and Usage

remove() method removes the selected element, including all text and child nodes.

This method does notremovethe matching elements from thejQueryobject, so these matching elements can be used again in the future.

But in addition to the element itself being retained, remove() will not retain the jQuery data of the element. Others such as boundevents, additional data, etc. will be removed. This is different from detach().

Syntax

$(selector).remove()

The difference between JQuery empty method and remove method

1. JQuery empty method
A. Definition and Usage
The empty() method removes all content from the selected element, including all text and child nodes.
B. Syntax
$(selector).empty();
2. JQuery remove method

A. Definition and usage
The remove() method removes the selected element. Includes all text and child nodes.

This method does not remove the matching elements from the jQuery object, so these matching elements can be used again in the future.

But in addition to the element itself being retained, remove() will not retain the jQuery data of the element. Others such as bound events, additional data, etc. will be removed. This is different from detach().
B. Grammar
The text in ;dsfsd

is removed, leaving

, which still retains its position in the dom.

$("p").remove() deletes it from the dom without retaining its position.

The above is the detailed content of Basic introduction to remove in jQuery and comparison of differences between empty. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!