Empty, remove, and jquerydom for DOM Node Deletion in jQuery

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.