简体   繁体   English

jquery scrollTo不工作

[英]jquery scrollTo not working

I'm just trying to scroll to a specific DOM element or absolute position in my browser window, and it's not working. 我只是想在我的浏览器窗口中滚动到特定的DOM元素或绝对位置,它不起作用。 Here's my code: 这是我的代码:

$(window)._scrollable();
$('#scene_01_down').click(function(){
    $(window).scrollTo(2000,1000);
});

and here's the documentation for the plugin: 这是插件的文档:

http://flesler.blogspot.com/2007/10/jqueryscrollto.html http://flesler.blogspot.com/2007/10/jqueryscrollto.html

Do you really need that plugin? 你真的需要那个插件吗?

$("html,body").animate({
    scrollTop: 2000,
    scrollLeft: 1000
});

To scroll to a particular element: 要滚动到特定元素:

var offset = $("#someElement").offset();
$("html,body").animate({
    scrollTop: offset.top,
    scrollLeft: offset.left
});

Demo. 演示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM