To clear all div’s contents inside a parent div with JavaScript, we set innerHTML
to an empty string.
For instance, we write
document.getElementById("masterdiv").innerHTML = "";
to select the outer div with getElementById
.
And then we set its innerHTML
property to an empty string to clear its contents.