Scrolling in JQuery
I want to scroll to a div + 100px
in the y
axis.
How开发者_高级运维 do I do that?
$.scrollTo('div100' + '100px', 2000)
doesn't work.
Assuming you mean the ScrollTo plugin, the documentation says you can pass some settings as the third argument, one of which can be offset
. So I guess something like this could work:
$.scrollTo('div100', 2000, { offset: { left: 0, top: 100 } });
I haven't tested this but should work
var element=$("#div100");
$(...).scrollTo( element.offset().left, element.offset().top + 100);
精彩评论