The jQuery remove function removes the selected element from the page and also removes the internal content of it. It removes everything of the selected element and in addition to this, it also removes the data and the events associated with the selected element.

See the example given below.
Example of jQuery remove

Output


Welcome to Tutorialdeep Web Tutorial.

Learn jQuery With Working Examples.

The above example contains the button and a div element which you have to remove using the jQuery remove method. When you click the ‘Click me’ button, the script removes the div element and all its internal child content.

Syntax of jQuery remove()

Sr. No Parameter Name Description
1 selector1 Specify the element you want to select and remove from the page. It is the required field.
2 selector2 Specify the element id or class name with this second parameter. You can select multiple element of same tag name using comma separated id or classname. It is the optional field.

jQuery Remove Multiple Elements of Same Type

If you want to remove multiple element of same HTML tag type, you can do so by using the second parameter of the remove() and using the comma separated ids or class name.

Example 1

Output


Welcome to Tutorialdeep Web Tutorial.

Tutorialdeep is a Web Development and Blogging Tutorial.

Learn Web Development Here.
Learn jQuery With Working Examples.

The above example removes the selected div element with multiple ids specify in the second parameter of the remove(). The argument to remove() passed with the comma separated ids of div element.
Example 2

Output


Welcome to Tutorialdeep Web Tutorial.

This is the first paragraph

This is the second paragraph

This is the third paragraph

The above example removes all the selected p elements with multiple class names specified inside the second parameter of the remove(). The argument to remove() is passing with the comma separated classnames of p element.

You must also learn:-

Leave a Reply

Your email address will not be published. Required fields are marked *