Javascript: How to delete all children elements of a DOM element
HTML:
<div id="foo">
...
</div>
Javascript:
var foo = document.getElementById('foo');
if (!foo) alert('Element with id "foo" not found!');
while (foo.firstChild) {
foo.removeChild(foo.firstChild);
}
No comments:
Post a Comment