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

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

WBOY
WBOYOriginal
2016-05-16 18:20:05826browse

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

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