26 of 119 menu

The remove method

The remove method completely removes the selected elements from the DOM. To remove elements without removing jQuery data and events associated with the elements, use the detach method.

Syntax

This is how we remove elements. Additionally, we can filter the selected elements by passing the optional parameter selector to the method:

.remove([selector]);

Example

Let's remove all paragraphs with the class www:

<p>text</p> <p>text</p> <p class="www">text</p> <p class="www">text</p> $('p.www').remove();

HTML the code will look like this:

<p>text</p> <p>text</p>

See also

  • method detach,
    which removes elements with the possibility of their recovery
  • method empty,
    which removes content from the selected elements
  • JavaScript method remove,
    which allows you to delete an element
azbydeenesfrkakkptruuz