【问题标题】:jQuery scroll on Mobile Safari移动 Safari 上的 jQuery 滚动
【发布时间】:2010-05-25 21:41:48
【问题描述】:

我正在开发网站,我需要它滚动到锚点。它需要动画,所以我决定使用 jQuery。我试过这个:

function goToByScroll(id){
      $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

它在桌面上完美运行。在 Mobile Safari 上,它首先转到页面顶部,然后滚动到我希望它滚动到的锚点。让它在 Mobile Safari 上运行的诀窍是什么?

【问题讨论】:

    标签: jquery iphone html scroll mobile-safari


    【解决方案1】:

    怎么样

    var top = $("#"+id).offset().top; //anchor top offset from doc top
    $(window).scrollTop(top);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多