.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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$(".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()
Call
What it does
jQuery collection
Elements to remove
selector
Filter which matched items are removed
Return
Same collection (now out of the document)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the element(s) you want to delete.
Step 2
Optionally pass a selector to narrow that set further.
Step 3
Call .remove() — nodes leave the document.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Official Demo: Remove Matched Elements
Delete every element with class hello from the document.
Filter text.:contains('Hello') keeps only the first.
Remove that one. The second paragraph remains.
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.