Bruno Bruno - 1 year ago 109
HTML Question

How to empty the content of a div

Does someone know how to empty the content of a div (without destroying it) in JavaScript?



Answer Source

If your div looks like this:

<div id="MyDiv">content in here</div>

Then this Javascript:

document.getElementById("MyDiv").innerHTML = "";

will make it look like this:

<div id="MyDiv"></div>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download