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 trial

JavaScript

Why isn't this children property working?

What am I doing wrong?

document.getElementsByTagName('nav').children;

Please either:

  • Paste your whole code in this question,
  • Paste your whole code in codePen and then copy the URL and paste it here. Or,
  • Tell us which video you're stuck on :-)

1 Answer

Hint, you are missing something with your children property.

Will .toUpperCase work? Nope

I dont think children is a method I tried it though to see and its not working. I'm confused because I thought children was a property with an array value of the elements children but a lot of the elements dont seem to have it a property. It looks like i'm adding an empty property to a lot of element when I try using this? I'm testing in the treehouse site console

nevermind I figured it out I needed to specify it was the first in the array returned by .getElementsByTagName

document.getElementsByTagName('nav')[0].children;