jQuery - Remove Elements
With jQuery, you can easily delete existing HTML elements.
Remove element /content
To delete elements and content, generally use the following two jQuery methods:
- remove ()-remove the selected element (and its children)
- empty ()-remove child elements from the selected element
jQuery remove() method
The jQuery remove () method removes the selected element and its children.
jQuery empty () method
The jQuery empty () method deletes the child elements of the selected element.
Filter deleted elements
jQuery remove () method also accepts a parameter that allows you to filter the deleted elements.
This parameter can be the syntax of any jQuery selector.
The following example deletes all class = "italic" <p> element：