Replacing all children of an HTMLElement?

If you simply want to replace all children, regarding of the type, why don’t you just set its content to ” and then add your code:

container.innerHTML = '';
container.appendChild( newContainerElements );

that would basically remove all the children in the fastest possible way 🙂

Leave a Comment