Home Course Remove Elements in jquery

Remove Elements in jquery

by MH RISHAD - 04 May 2019

There are mainly two jQuery methods:

remove() - Removes the selected element (and its child elements) Also can be delete

empty() - Removes the child elements from the element, Which are selected

What is remove() Method

The jQuery remove() method removes the selected element(s) and also its child elements.



What is empty() Method

The jQuery empty() method removes the child elements of the selected element(s).



Filter the Elements to be Removed

The remove() method also accepts one parameter, which allows you to filter the elements to be removed.

The parameter can be any of the selector syntaxes.

Following example removes all <p> elements with class="test": 




This example removes all <p> elements with class="test" or class="test2": 


$("p").remove(".test, . test2");

Leave a Comment

Required fields are marked *