Search code examples
javascriptdojo

Remove all child nodes


How to remove all child nodes from <div id="test"></div> using Dojo or plain JavaScript?


Solution

  • dojo.empty(node) will remove all children from the node, while keeping the node.

    dojo.destroy(node) will remove all children from the node, and then removes the node from its parent as well.