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 trialRavit Ben-Shlush
3,689 Pointswhy the dots between mouseMove(), mouseUP(), mouseDown()...
why is it mouseDown().mouseMove().mouseUp() ? why theses functions are not separated?
3 Answers
Justin Iezzi
18,199 PointsHi Ravit,
This is a syntax called method chaining. Method chaining is used to invoke multiple methods at once. Gregory Schier wrote a really nice article about this on his blog, see here. You can also find many other resources regarding method chaining via Google.
Pavle Lucic
10,801 PointsIt is called method chaining, where a method returns the object which it called it.
Ravit Ben-Shlush
3,689 Pointsthe order should matter, right?
Pavle Lucic
10,801 PointsIn this example, answer is no.
.mouseup( handler )
handler
Type: Function( Event eventObject )
A function to execute each time the event is triggered.
This is from jquery docs.
Important part is handler. By that I mean what function will execute on mouse up.