Empty an element’s content
jQuery $.empty()
2015 page
This is the original page from 2015, kept at its address while the tested rewrite is in progress. The code is of its time: it ran in Internet Explorer and does not use what browsers have gained since. The rewrite replaces it here.
In short
Remove all child nodes of an element from the DOM.
Use the innerHTML property of an element for removing all child elements, and thus clearing its content:
var el = document.querySelector('div');
el.innerHTML = '';Event handlers bound to any part of the element’s content are destroyed in the process.