jQuery Remove Selected Element

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

Test it Live

Output


Welcome to Tutorialdeep!

Learn jQuery With Live 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 elements of the 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.

Test it Live

Output

When you click the button, it removes all the contents given below.

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 specified in the second parameter of the remove(). You have to pass the argument as comma-separated ids of div element.

You must also learn:-