How to empty the content of a div

html, javascript

Solution

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>`

Problem

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

Original source

Related problems