Empty, remove, and jquerydom for DOM Node Deletion in jQuery
Preface
I just learned new things recently. Although it is a small knowledge point, I can't help but share it with you. The content of this article is mainly for beginners. If you have any comments or questions, you can leave a message. Let's take a look at the details.
.empty()
Deletes the child of the node. The result is that the node is cleared (no element exists in the node ).
.remove()
This node is deleted, and the result is that it is deleted (the node and its descendant elements will not exist ).
The following code is used to describe it.
<! DOCTYPE html>
Click "run". The following figure is displayed.
Click button1 to execute.empty()
Command, which is expected to delete the element of the test1 subnode. The result is as follows.
Click button2 to execute.remove()
Command. It is expected that the elements of test2 and its child nodes will be deleted. The result is as follows.
Summary
The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.