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

jQuery remove() method

jQuery remove() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Remove all the

element:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

p

"

)

.

remove

(

)

;

}

)

;

Try it »


Definition and Usage

The remove() method removes the selected elements, including all text and child nodes.

This method also removes the data and events of the selected elements.

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

**Tip:** To remove only the content from the selected elements, use empty() method.


Syntax

$(

selector

).remove()


More examples

The difference between detach() and remove()
Demonstrates the difference between the detach() and remove() methods.


jQuery HTML/CSS methods jQuery HTML/CSS methods