Hello, I’m working on the remove an element lesson. I’m getting confused on when to use ‘document’ vs ‘document.body’ or when I even need to use them at all. Take for example the above lesson, here is the answer:
let child = document.getElementById('oaxaca') let parent = document.getElementById('more-destinations') document.removeChild(child) //doesn't work document.body.removeChild(child) // doesn't work parent.removeChild(child) // works
I read this post on stackoverflow which I understood as meaning that I don’t have to include ‘body’ because it limits the search for the element. Can someone please clear this up in my mind?