Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (1.5k points)
recategorized by
Can i remove child node in HTML using Javascript? if yes, please tell me how to do that.

1 Answer

0 votes
by (1.4k points)

If you wanto clear the div and remove all child nodes, you can use: 

var mydiv = document.getElementById('FirstDiv'); 

while(mydiv.firstChild) { 

  mydiv.removeChild(mydiv.firstChild); 

} 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...