【问题标题】:jQuery scroll to top of iOS address barjQuery滚动到iOS地址栏顶部
【发布时间】:2012-03-05 21:21:18
【问题描述】:

jQuery 的.animate({ scrollTop: '0' }, 600 }); 将iOS 滚动到页面顶部,但不会滚动到绝对顶部(显示地址栏)。有什么办法可以打鹅吗?

谢谢!

【问题讨论】:

    标签: jquery ios scroll jquery-animate


    【解决方案1】:

    $('body').scrollTop(0); 将页面的滚动位置设置为页面顶部,而$('body').scrollTop(); 将返回当前滚动位置。

    【讨论】:

      【解决方案2】:
      // Will scroll to the top and will show the address bar
      $('body').scrollTop();
      
      // Will scroll to the top and won't show the address bar
      $('body').animate({ scrollTop: '0' }, 0)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-15
        • 1970-01-01
        相关资源
        最近更新 更多