Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery empty() method

jQuery empty() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Remove all

element's content changes:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

div

"

)

.

empty

(

)

;

}

)

;

Try it »


Definition and Usage

The empty() method removes all child nodes and content from the selected elements.

**Note:** This method does not remove the elements themselves or their attributes.

**Tip:** To remove the elements but keep their data and events, use detach() method.

**Tip:** To remove the elements along with their data and events, use remove() method.


Syntax

$(

selector

).empty()


jQuery HTML/CSS methods jQuery HTML/CSS methods