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 Password Confirmation Form Perform: Part 1

Is there any disadvantage to using .on('focus keyup') rather than .focus().keyup()?

I've been previously been taught that the on() method is the best way to attaching event handlers. So my code looks like:

$('#password').on('focus keyup', passwordEvent);

rather than:

$('#password').focus(passwordEvent).keyup(passwordEvent);

Am I following best practice? Do I need to rethink this?

1 Answer

...

Keep calm

and

call .on()

Is a sticker I have on my monitor to encourage me to do it the right way and not be lazy. :)