Remove all child nodes

Javascript DOM method remove() allows only the calling node to be deleted. But what if you only want to delete all the child nodes in it ?

Demo

child 1

child 2

child 3

For the sake of this API, let's say that you have a div that has 3 child nodes. And you have a button which when clicked will call a Javascript function.

Then finally, you can create that Javascript function and call the at.removeAllChildNodes method to remove all the children in it.

at.removeAllChildNodes: function accepts the parent node as an argument.