jQuery - Remove Elements
With jQuery, it is easy to remove existing HTML elements.
Remove Elements/Content
To remove elements and content, there are mainly two jQuery methods you can use:
- remove() - Removes the selected element (and its child elements)
- empty() - Removes child elements from the selected element
jQuery remove() Method
The jQuery remove() method removes the selected element and its child elements.
jQuery empty() Method
The jQuery empty() method removes the child elements of the selected element.
Filter the Elements to be Removed
The jQuery remove() method also accepts a parameter, allowing you to filter the elements to be removed.
This parameter can be any jQuery selector syntax.
The following example removes all <p> elements with class="italic":
Other Extensions