jQuery Document Manipulation - remove() Method
Example
Remove all <p> elements:
$("button").click(function() { $("p").remove(); });
Definition and usage
The remove() method removes the selected elements, including all text and child nodes.
This method does not remove the matched elements from the jQuery object, so these matched elements can be used again in the future.
The remove() method does not retain jQuery data for the element itself, other than the element itself is preserved. This includes events bound, data attached, and so on. This is different from detach().
Syntax
$(selector.remove()
More examples
- Move elements
- Use the remove() method to move elements.