Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Ramirez
3,029 Pointshow would you answer this?
How would you select the body element using document.getElementsByTagName, and store it in the variable body?
(Hint: Don't forget that this method returns a collection, not a single element.)
const body =
Michael Ramirez
3,029 Pointsive already looked through that site, did not help. keeps saying the answer is wrong.
Gari Merrifield
9,598 PointsAnd what did YOU try for your answer?
Tucker Blackwell
3,397 PointsI don't understand what you're getting at. Why not just select it with document.querySelector? Though I get that you're trying to ask a tricky question, there would literally be 0 use cases for using getElementsByTagName to select the body, so therefore, I think this question is pointless and doesn't really merit any deeper thought.
Gari Merrifield
9,598 PointsTucker : I think you are missing the entire point. This is a quiz question, not Michael's own.
Michael : It looks like this was covered previously on the forums : https://teamtreehouse.com/community/how-do-you-select-the-htmls-body-using-documentgetelementsbytagname
1 Answer
Tucker Blackwell
3,397 PointsOhhhh. lol my bad. I wasn't actually working through this course I just got an email from Treehouse inviting me to answer random questions. I should have looked into it a bit more before answering. My apologies, Michael.
Gari Merrifield
9,598 PointsGari Merrifield
9,598 PointsIt looks like they have basically given you the answer. If you are not understanding it, you may need to rewatch the videos, or look in the Teachers Notes, they probably have a link to the DOM reference at MDN.
This part may give you more clues : https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName