Intellipaat Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (1.5k points)
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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...