function clearChildren(node) { while (node.hasChildNodes()) node.removeChild(node.firstChild); return node; } function clear_depths(start_by) { var empty = document.createTextNode("123"); for(i=start_by;i<=10;i++) { element = document.getElementById("depth"+i); // I need this step that give me the node from the element clearChildren(node); node.appendChild(empty); } }