ExampleRemove all p elements:
Try it yourself » |
The detach() method removes the selected elements, including all text and child nodes.
This method keeps a copy of the removed elements, which allows them to be reinserted at a later time.
The detach() method also keeps the element's jQuery data, like event handlers.
$(selector).detach() |
![]() |
Try it Yourself - Examples |
Remove and restore an element
How to use the detach() method to remove and restore an element.
Move an element and keep its click event
How to use the detach() method to move an element, and keep the element's jQuery data.