jQuery remove() Method

jQuery remove() method can be used to remove the selected elements including all the texts and content. The method also removes data and events of the selected elements.

jQuery remove() Method

Syntax

The syntax of this method is given below:-

Syntax
$(selector).remove(innerselector)

Description of the Parameters

The description of these parameters is given below.

Parameter Name Description
selector Specify the element to select and remove the element including text and nodes. You can use the element tag name, class name, or id to select. It is a required field.
innerselector Specify the single or multiple comma-separated classes or id of the element to remove. You have to use the class name, or id to select. It is an optional field.

jQuery remove() Method to Remove Single Element

If you want to remove the element as well as its content and nodes, you have to use this method as given below. You have to specify the element to select and remove.

Example

Test it Live

Output

This is my paragraph. Learn jQuery and other technical skills from Tutorialdeep.


Click the button given above to remove the element and its content. It also removes the b element which is the child node of the selected element.

Remove Multiple Specified Element

You can also remove multiple elements using the jQuery remove() method. Specify the comma-separated class name or ids of the element to remove.

Example

Test it Live

Output

First paragraph.

Second paragraph.

Third paragraph.


There are three paragraph element in the above example. When you click the button given above, it removes all the paragraphs given above. The above example showing the class names specified as the parameter of the method.

You may also like to read

I hope you like this tutorial on jQuery remove() method. If you have any queries regarding the tutorial, please comment below.

References