I have the following:
<div id="test">
...
...
</div>
I would like to remove all of the elements within the div so I tried:
$('#test > div').remove();
But this doesn't seem to work. Am I doing the right thing here?
try with right syntax
Remove : Remove the set of matched elements from the DOM.
$('div#test').remove();
try with empty
empty : Remove all child nodes of the set of matched elements from the DOM.
$('#test').empty();
see html() also, sometime it is helpful
html: When .html() is used to set an element's content, any content that was in that element is completely replaced by the new content.
Note: To remove the elements without removing data and events, use .detach() instead.
$("#test").empty()
should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With