Reputation: 1708
I am a bit confused to try to understand the difference between the jQuery method scrollTop() and property scrollTop. Actually i read about jQuery method scrollTop() at several places on Internet but very surprisingly i didn't read anywhere that scrollTop is also a jQuery property. I am not sure about it but though i saw in many code of animate() method, people using scrollTop: value to scroll the page. So please let me understand about this. Is there any resource on Internet which can tell scrollTop can also be used a property.
Upvotes: 1
Views: 891
Reputation: 70209
jQuery's .scrollTop()
method wraps the native Element.scrollTop
property.
That is, the .scrollTop()
method belongs to jQuery objects while the property belongs to native elements. The two won't be present in the same object.
i saw in many code of animate() method, people using scrollTop: value to scroll the page
Yes, scrollTop
is an animatable property. See .animate()
docs:
In addition to style properties, some non-style properties such as
scrollTop
andscrollLeft
, as well as custom properties, can be animated.
Is there any resource on Internet which can tell scrollTop can also be used a property.
The jQuery API Documentation and MDN are the places to look for this information.
Upvotes: 2