开发者

Get axis-x position inside scrollable div

I have a scrollable div which overflow is hidden. I am usin开发者_Go百科g this plug-in to scroll the div. How can I detect the axis x position with jquery (or maybe with this plug-in) so if there is nothing to scroll on left, I would be able to hide the left arrow, and show it again when the axis has moved?


Look at the scrollLeft property.

It can be accessed like an attribute in jQuery.

var scrollLeft = $('element').attr('scrollLeft');

jsFiddle.

To determine if the user has scrolled all the way to the left, check for (scrollLeft == 0).

To see if they have scrolled all the way to the right, you should be able to do (scrollLeft == element.attr('scrollWidth') - element.width()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜