← Back to Index

.empty()

Remove all child nodes of the set of matched elements from the DOM.

Examples

1. Clear content

// <div class="container"><p>Text</p></div>
$('.container').empty();

Result

<div class="container"></div>

Details

This method proactively cleans up internal data and event listeners attached to the child elements before removing them, preventing memory leaks.

Returns: The original SR object for chaining.