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 .animate question

On w3schools.com, they say the "params" defines the CSS properties to be animated.

$(selector).animate({params},speed,callback);

But I see we can also insert other functions { scrollTop: 0 } into the same area, which isn't CSS.

function $nameHere () { $('body,html').animate({ scrollTop: 0 }, 800); }

Could someone just explain why, and what other functions can be used here also.

Thanks :D

2 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

On the official documentation it says "In addition to style properties, some non-style properties such as scrollTop and scrollLeft, as well as custom properties, can be animated."

Fantastic! I will have a play with scrollLeft also.

Thank you.