Sir
Sir

Reputation: 8280

Removing a div with child divs

I was wondering if i remove a div which had div's inside of it using :

var div = document.getElementById('main');
div.parentNode.removeChild(div);

Will this also remove all the Divs that are inside of it ? Or will i have to clear innerHTML first?

Upvotes: 0

Views: 81

Answers (1)

DA.
DA.

Reputation: 40673

If you remove an element from the DOM, you remove its children as well.

Upvotes: 4

Related Questions