开发者

Scrolling in JQuery

开发者 https://www.devze.com 2022-12-09 04:10 出处:网络
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

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);
0

精彩评论

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