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 jQuery Basics (2014) Creating a Spoiler Revealer Using click()

Eric Shomer
Eric Shomer
1,091 Points

event handler?

I have been using the event handler .on('click', function() { //code}); for months now, then decided to go through this course, and apparently this is wrong? It wants me to use the shorthand .click?

2 Answers

Brent Suggs
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Brent Suggs
Front End Web Development Techdegree Graduate 21,343 Points

Yes, the jQuery click() function is just an easier way to do and actually does the exact same thing. jQuery will use the .on('click', function(){...}); JavaScript function for you. I would suggest review the videos some more to get a better handle on what jQuery is and how it works. You were not wrong for using .on('click', function(){...}); because that is how Javascript handler works, but jQuery simplifies things for you.