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 trialSimon Coates
28,694 PointsIs 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.
3 Answers
Joel Kraft
Treehouse Guest TeacherSimon,
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
Simon Coates
28,694 Pointsthanks joel!
Joel Kraft
Treehouse Guest TeacherIt 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. :)
nfs
35,526 PointsHey, Simon,
That's a very interesting thing you pointed there !!!
nfs
35,526 PointsUpdate: they did...
nfs
35,526 PointsIt's ok, Joel Kraft. Thank you.
Simon Coates
28,694 PointsSimon Coates
28,694 PointsFor 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.