function removeAllChildNodes(parent) { while (parent.firstChild) { parent.removeChild(parent.firstChild); } } Code language: PHP (php)