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 Introduction to jQuery Hello, jQuery! Why jQuery?

Simon Coates
Simon Coates
28,694 Points

Is the vanilla JS code posted around the 4 minute mark completely wrong?

Not sure there's a getElementByTagName method on document and the getElementsByTagName returns a collection, which i'd assume you'd need to loop over to attach events using vanilla JS. I appreciate the code in question is for demonstration purposes, but might have potential to muddy the waters.

Simon Coates
Simon Coates
28,694 Points

For the record, I think they may have fixed this. So if you look at the code and it seems okay, then you probably aren't going crazy. From memory, the problem at the time was that they seemed to expect vanilla JS to behave like jQuery. The current code reflects the need for looping and my concern about attaching events.

3 Answers

Joel Kraft
STAFF
Joel Kraft
Treehouse Guest Teacher

Simon,

You're right, that vanilla JS code is problematic and wouldn't work. We'll look into updating this video. Thanks for letting us know!

Joel

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

It was indeed updated, as both Simon Coates and Nafis Fuad mentioned. Sorry I didn't post back sooner! And thanks for keeping an eye on it. :)

Hey, Simon,

That's a very interesting thing you pointed there !!!

Update: they did...

It's ok, Joel Kraft. Thank you.