jQuery empty Method
jQuery empty Method : is used to remove the children elements of selected element from the DOM. It removes the child elements of the selected element. $(selector).empty() is used to empty ie. remove child elements of the selector ie selected element. We are going to explain this method with example and demo.
Note : Empty method removes only child elements not the selector element.
Syntax
Syntax for empty method –
$(selector).empty();
jQuery empty Method Example
Below example shows the empty method try it –
jQuery empty() Method – Example
<script type="text/javascript"> $(document).ready(function(){ $( "#emptyExample" ).on( "click", function(event) { $("#emptyMe").empty(); }); }); </script> |
The above example will produce following output-
Advertisements