Code has been added to clipboard!

jQuery .remove(): Delete Elements With Their Content, Events and Data

Reading time 1 min
Published Jan 22, 2018
Updated Sep 27, 2019

jQuery remove: Main Tips

  • jQuery .remove() function deletes the selected element with all of its content.
  • It eliminates all events and data associated with the specified elements.
  • To remove elements but keep their data and events, apply .detach() instead.

Usage of .remove()

If you wonder which jQuery method is used to remove selected elements, you should know there's more than one answer. However, only jQuery .remove() gets rid of the selected elements including their children, nodes, text, events, and data.

See in the example below how jQuery .remove() function is used to remove a link:

$("button").click(() => {

Follow this syntax to delete element jQuery has:


A selectorExpression is an optional parameter used to filter the set of elements to be removed.

Tip: to remove descedants and string texts within elements, use .empty() instead of jQuery .remove().

Latest Coupon Found:



Learn the skills of tomorrow

The best time to learn programming is now - follow this link to access 100+ coding courses and enjoy learning at a very low cost!

Expiration date: 18/04/2021
2287 People Used
Only 92 Left