jQuery - Element Removal

It is simple to eliminate HTML elements with jQuery.

Element/Content Removal

There are 2 major jQuery processes for removing elements and subject matter:

remove() - Removes the quick access element (and its child elements)

empty() - Eliminates this same selected element's child elements.


remove() method in jQuery

The jQuery eliminate() method deletes the chosen element(s) and all of its children.

Illustration:

EXAMPLE ❯


Method empty() of jQuery

The empty() method of the jQuery library eliminates the chosen element's child components (s).

Illustration:

EXAMPLE ❯


Eliminate the Elements by Sorting

The remove() method in jQuery also takes each variable, that also makes it possible users to sort the elements which will be eliminated.

Any of jQuery selector syntaxes could be used as the parameter.

This same illustration below eliminates most p> elements with class="test":

Illustration:

EXAMPLE ❯


All p> elements with the classes="test" and "demo" are eliminated in this illustration:

Illustration:

EXAMPLE ❯