jQuery Empty Method

The jQuery empty function removes all the internal content including HTML elements of the selected element. It does not remove the selected element but removes content inside the selected element.

Example of jQuery empty

Test it Live


When you click the button, it makes below content empty.

Welcome to Tutorialdeep Web Tutorial.

Learn jQuery With Working Examples.

The example given above contains the button and the div element which you have to make empty using the jQuery empty method. When you click the ‘Click me’ button given above, the script makes the div element empty by removing all the child content of the selected element.

Syntax of jQuery empty()

Sr. No Parameter Name Description
1 selector Specify the element you want to select and make it empty by removing the child elements. It is the required field.

jQuery Empty Multiple Elements on Click

If you want to empty multiple elements of the same HTML tag type, you can do so by adding click event on all the div. Here, see below example to find out how you can perform this task.

Test it Live


Click below colored div’s to make them empty.

Tutorialdeep is a Web Development and Blogging Tutorial.

Learn Web Development Here.
Learn jQuery With Working Examples.

The above example makes all the clicked div’s empty. The script uses the class name of the div to select the element and apply the jQuery empty method.

You must also learn:-