

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 node using jQuery?
Use the jQuery empty() method to remove all child nodes from a parent node.
Example
You can try to run the following code to remove all child nodes from a parent node using jQuery:
<!DOCTYPE html> <html> <head> <style> </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#button1").click(function(){ $("ul").empty(); }); }); </script> </head> <body> <div> <ul> <li>li (child)</li> <li>li (child)</li> <li>li (child)</li> <li>li (child)</li> </ul> </div> <button id="button1">Remove</button> <p>Click Remove to remove all child nodes.</p> </body> </html>
- Related Questions & Answers
- How to remove all child nodes from a parent using jQuery?
- How to remove all child nodes from a parent in jQuery?
- jQuery parent > child Selector
- Remove all child elements of a DOM node in JavaScript?
- Program to remove all nodes with only one child from a binary tree in Python?
- How can I remove a child node in HTML using JavaScript?
- How can I remove all child elements of a DOM node in JavaScript?
- Python Program to Find All Nodes Reachable from a Node using BFS in a Graph
- How to select ALL children (in any level) from a parent 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 to get the child element of a parent using JavaScript?
- How to remove all the elements from DOM using element ID in jQuery?
- Remove the child node of a specific element in JavaScript?
Advertisements