- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove all child nodes from a parent in jQuery?
To remove all child nodes from a parent in jQuery, use the empty() method.
Example
The jQuery empty() method removes all child nodes of the set of matched elements from the DOM.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function() { $("#demo").empty(); }); }); </script> </head> <body> <ul id='demo'> <li>India</li> <li>US</li> <li>UK</li> </ul> <button>Remove all child nodes</button> </body> </html>
- Related Articles
- How to remove all child nodes from a parent using jQuery?
- How to remove all child nodes from a parent node using jQuery?
- jQuery parent > child Selector
- Program to remove all nodes with only one child from a binary tree in Python?
- How to select ALL children (in any level) from a parent in jQuery?
- How to expand JTree row to display all the nodes and child nodes in Java
- How to remove all the elements from DOM using element ID in jQuery?
- How to remove all style attributes using jQuery?
- How to remove all CSS classes using jQuery?
- How to remove all CSS classes using jQuery?
- How will you travel from child to parent with xpath in Selenium with python?
- Program to remove all nodes from BST which are not in range in Python
- How to call parent constructor in child class in PHP?
- Remove all child elements of a DOM node in JavaScript?
- How to get the child element of a parent using JavaScript?

Advertisements