Home > Web Front-end > JS Tutorial > Explanation of the difference between empty() and remove() in jquery_jquery

Explanation of the difference between empty() and remove() in jquery_jquery

WBOY
Release: 2016-05-16 18:20:05
Original
898 people have browsed it

1.empty() only removes all child nodes in the specified element. Take $("p").empty() as an example, it just removes

dsfsd< The text in /p> is removed, leaving

, which still retains its position in the dom.

2.remove([expr]) deletes it from the dom without retaining its position.

Example:

Hello

World

welcome

Execute $("p").empty() and the result is

World

Execute $("p").remove() and the result is World

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template