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 Events Using the on() Method

Samuel Cleophas
Samuel Cleophas
12,348 Points

What is a 'Short hand property' !?

Hello there!

I don't know if it's just me, but I find these jQuery lessons a little annoying since it consists of a lot of assumed knowledge.

I don't know what a shorthand property is, and why that is a benefit of using the 'on()' method.

Thanks. Samuel

1 Answer

nico dev
nico dev
20,364 Points

I hear you, I've been there a lot of times! |o| Like I finish a video and I am totally shocked saying "Oh no, how did he do that?", how will I ever understand and let alone do that.

However, truth is we're always encouraged to not just watch the video, but also do our own research and practice with things happening during videos, and I can attest that 99.9% of the times, these help you solve your doubt, learn a new thing, and even gain more confidence for the next challenge coming ahead.

Now coming to the specific challenge you have, a shorthand property is, defined in the briefest and simplest way possible, a shorter or more efficient way to do/write/type something, and doing more with less code, following a certain 'convention'. So it can either make you type less or give you more flexible possibilities, or even both.

If you've been to CSS, which I suspect you already did, a common example is the background shorthand property. Instead of writing the background-color, background-image, background-size, background-repeat, and an endless etcetera, you just say background and assign it the values in a certain order.

The jQuery on() is a shorthand property in the sense that in pure JS, you'll need to use a different solution for each event, for example if you have a scroll event, instead of a click one, you'll need a different solution in JS, onclick() will not work, whereas in jQuery, you'll just change the .on('click',.... by .on('scroll'...), I don't know if that's the greatest example, but at least it makes it explained that the versatility, let's say, is what is meant here by shorthand.

Hope that helps clarify it a bit. You can read more here. (And, just as an additional note, there also seems to be another jQuery intro course on the road map coming soon).

Samuel Cleophas
Samuel Cleophas
12,348 Points

Dude. Great answer. I hope you're right. Because I didn't realise 'on()' was a property. I thought it was a method.

Regardless, thanks so much for the help and encouragement. I'm coding 5 hours a day, but it's not always rosy and filled with excitement..

Cheers. :)