Select the parent, clear its contents, then optionally refill.
Select the container element(s) you want to wipe.
Call .empty() — no arguments.
Children (and nested descendants) are removed; the parent remains.
Chain .append() / .html() if you need new content next.
Piece
Required?
Role
Matched set
Yes
Parent container(s) to clear
Arguments
None
.empty() takes no parameters
Return
—
Same jQuery collection (chainable)
Pseudocode
Pseudocode
for each matched element el:
for each child (and descendant) of el:
remove jQuery data and event handlers
remove child from the DOM
// el itself stays
return original matched set
// Text nodes count as children — they are removed too
Reference
Cheat Sheet
Keep these facts handy while clearing containers.
Topic
Detail
Syntax
.empty()
Since
jQuery 1.0
Removes
All children + descendants + text
Keeps
The matched parent element
Cleanup
Child data and handlers cleared
vs remove
Parent stays vs parent deleted
vs detach
Destroy children vs park nodes
Try it
Live Preview
Clear a paragraph with .empty(), or reset and refill it.
Browser demo of .empty() — same idea as the examples below.
Hello, Person and person.
Result
$("p").empty()
→ parent <p> remains; children gone
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Deep clear. Not only direct children — all descendants go.
Cleanup. jQuery strips data/handlers on those nodes first.
Parent.#panel remains an empty container.
Tip. Prefer this over looping .remove() on every child.
Edge Cases & Pitfalls
Check these before wiping a live container.
handlers
Child handlers are destroyed
If you need those nodes again with events intact, .detach() them instead of emptying the parent.
args
No selector argument
.empty() always clears everything inside. To remove a subset, select those children and call .remove().
parent
Parent data stays
.data() and handlers on the matched parent itself are not cleared by .empty() — only descendants are cleaned.
html
.html("") is not clearer intent
Prefer .empty() when you mean “clear children.” Use .html() when you are setting new markup.
Compatibility
Browser Support
.empty() has been part of jQuery since 1.0. It works wherever your loaded jQuery version runs.
✓ Stable · jQuery 1.0+
jQuery .empty()
Supported in all browsers that run jQuery 1.0+. Prefer a current jQuery 3.x build for modern projects.
100%jQuery core method
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.empty()Universal
Bottom line: Safe for clearing containers before rebuild. Use .detach() when child handlers must survive.
Analysis
Performance Notes
Approach
Cost
Best for
.empty()
One clear + cleanup
Wiping a container
Loop .remove() on children
More work
Avoid — prefer empty
.empty().append(…)
Clear + insert
List redraws from data
For large lists, empty once, then append a batch (or a fragment). Avoid repeatedly emptying inside a tight animation loop.
Remember
Key Takeaways
Role: remove all children; keep the parent.
Text too: text nodes are children and get cleared.
vs remove: empty keeps the shell; remove deletes it.
Rebuild:.empty().append(…) for fresh lists.
One line:.empty() wipes a container clean so you can keep the parent and refill it.
Frequently Asked Questions
.empty() removes all child nodes from each matched element — text and nested elements — while the parent stays in the DOM. Returns the same jQuery collection for chaining. Available since jQuery 1.0.
.empty() clears inside the matched element and leaves the parent. .remove() deletes the matched elements themselves. Use empty to wipe a container; use remove to delete the container too.
.empty() destroys children and cleans their jQuery data/handlers. .detach() removes matched elements but keeps data and handlers for later reinsertion. Use empty to clear contents; use detach to stash whole nodes.
Yes. In the DOM, text inside an element is a child node. .empty() removes text as well as element children.
No. To remove only some children, select those descendants and call .remove() or .detach() on them.
Yes. jQuery removes data and handlers from child elements before removing them, which helps avoid memory leaks.
Both can clear contents. .empty() is the dedicated clearer and always cleans child data/handlers. Prefer .empty() when your intent is “clear this container.”