.remove([selector]) takes matched elements out of the DOM — the elements themselves and everything inside them (since jQuery 1.0). Bound events and jQuery data are removed too.
Remember
$(".hello").remove()
$("div").remove(".hello") // filter
$("p").remove(":contains('Hello')")
// delete the element itself
// keep parent, clear children → .empty()
// remove but keep data/events → .detach()
Select the nodes to delete, optionally filter, then call remove.
Select the element(s) you want to delete.
Optionally pass a selector to narrow that set further.
Call .remove() — nodes leave the document.
jQuery clears associated data and event handlers automatically.
Piece
Required?
Role
jQuery collection
Yes
Elements to remove
selector
Optional
Filter which matched items are removed
Return
—
Same collection (now out of the document)
Pseudocode
Pseudocode
set = matched elements
if selector given:
set = set filtered by selector
for each element in set:
clear jQuery data and events
remove element (and children) from the DOM
return set
// Official idea:
$(".hello").remove()
$("div").remove(".hello") // same effect here
Reference
Cheat Sheet
Keep these facts handy while deleting nodes.
Topic
Detail
Syntax
.remove([selector])
Since
jQuery 1.0
Deletes
Element + descendants
Data / events
Cleaned up
vs .empty()
Deletes self vs clears children only
vs .detach()
Discards vs keeps jQuery state
Filter
Optional selector argument
Try it
Live Preview
Run official-style remove actions on a tiny demo tree and see which nodes disappear.
Browser demo of .remove() — same idea as the examples below.
Result
Ready — pick an action and run.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Official Demo: Remove Matched Elements
Delete every element with class hello from the document.
After empty: <div id="box"></div>
After remove: (no #box)
How It Works
empty. Children are cleared; the parent shell stays.
remove. The parent itself is deleted from the DOM.
Pick by intent. Clear a list shell → empty; delete a widget → remove.
See also. Need to put it back later? Prefer .detach().
Edge Cases & Pitfalls
Check these before deleting nodes in real pages.
state
Cannot restore data after remove
Handlers and .data() are gone. Use .detach() if you plan to reinsert.
scope
Children are deleted too
Removing a parent removes nested content. To keep the parent, use .empty().
filter
Selector filters the matched set
$("div").remove(".hello") only removes divs that also match .hello.
query
Gone from the document
After remove, a normal selector will not find those nodes again.
Compatibility
Browser Support
.remove() is a core jQuery method (since 1.0). It needs a browser DOM with jQuery loaded.
✓ jQuery 1.0+ · Browsers only
jQuery .remove()
Works in Chrome, Firefox, Safari, Edge, and other browsers with jQuery. Not for Node.js without a DOM.
100%Browser support
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
.remove()Browsers
Bottom line: Use .remove() in the browser to delete elements permanently. Prefer .detach() when you need to put them back with data intact.
Analysis
Performance Notes
Approach
Cost
Best for
.remove()
Low–moderate
Permanent deletion + cleanup
.empty()
Similar
Clearing a container you will reuse
.detach()
Similar
Temporary removal with state kept
Prefer one targeted remove over many tiny deletes in a loop when you can. Removing large subtrees also cleans nested jQuery data — that is intentional, not wasted work.
Remember
Key Takeaways
Role: delete matched elements (and their children) from the DOM.
Cleanup: jQuery data and events are removed too.
Filter: optional selector narrows what gets deleted.
Choose: empty to clear; detach to park; remove to discard.
One line:$el.remove() deletes the element for good — including children, data, and events.
Frequently Asked Questions
.remove() takes matched elements out of the DOM — the elements and everything inside them. It also cleans up bound event handlers and jQuery data. Returns the same jQuery collection. Available since jQuery 1.0.
Both remove nodes from the document. .remove() also discards jQuery data and events. .detach() keeps that state so you can reinsert later. Use remove when nodes will not come back.
.remove() deletes the matched elements themselves. .empty() keeps the matched parents and only clears their children. Use remove to delete a widget; use empty to clear a container shell.
Yes. Pass an optional selector: $('div').remove('.hello') removes only divs that also match .hello. Same idea as .filter(selector).remove().
Yes. Handlers bound with .on() and the internal data cache are cleared to help avoid memory leaks. If you need handlers after removal, use .detach() instead.
The same jQuery collection that was removed. Those nodes are no longer in the document, so you cannot find them again with a normal selector query.