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 trialDavid Soards
18,368 PointsButton still works
The button still works for me after moving the click event to the top of the app.js. I even cleared the cache in Chrome and it still work. This is NOT a problem, obviously. Just an observation. I'm guessing it has to do with Chrome's JS engine being "smart."
2 Answers
Steven Parker
231,261 PointsIt doesn't matter where in the file you place the code to establish the button click handler. The entire file runs immediately on page load, but the handler itself doesn't run until the button is clicked.
David Soards
18,368 PointsI jumped the gun on this post. I was targeting '.spoiler' instead of '.spoiler button' for the .click When targeting '.spoiler button' the behavior is the same as in the video. Sorry!