How can I delete content of div with jquery?
example of div id container
input:
<div id="container">
<h1>sdsdsdsd</h1>
dsdsdsdsds
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
dsfdfsd
</div>
output:
<div id="container">
</div>
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
.empty(), like this:You can give it a test here, it’s important to use
.empty()or.remove()when you have events/data bound to any descendants inside what you’re clearing…otherwise you’re leaking memory that won’t be cleaned up.