滚动到无法在手机上工作的页面顶部
scroll to top of page not working on mobile
我已经研究并尝试从SO实现许多解决方案,但无法使其发挥作用。我尝试过使用iscroll库,设置超时等
当用户单击按钮时,我想滚动到移动电话设备中的窗口/页面的顶部。
$('.box').click(function(){
document.body.scrollTop = 0;
});
这里有一个版本,它可以处理所有文档;)
// ===== Scroll to Top ====
$(window).scroll(function() //When the page is being scrolled
{
if ($(this).scrollTop() >= 150) // If page is scrolled more than 150px
{
$("#return_to_top").fadeIn(200); // Fade in the arrow, 200 means that arrow will be shown in 200 miliseconds (fast) - 600 means slow, 400 is normal
}
else
{
$("#return_to_top").fadeOut(200); // Else fade out the arrow, fast
}
});
$(document).ready(function() //When the page is ready, load function
{
$("#return_to_top").click(function() // When arrow is clicked
{
$("body,html").animate(
{
scrollTop : 0 // Scroll to top of body
}, 400); //how fast the scrolling animation will be in miliseconds
});
});
相关文章:
- jQuery偏移量顶部没有'工作不正常
- 如何停止两个按钮执行相同的工作?在这种情况下,它们都会滚动到顶部
- 固定顶部导航的impress.js无法工作
- 滚动到不与溢出一起工作的顶部脚本:滚动
- 当设置为导航栏固定顶部时,一页引导导航栏切换在移动模式下无法正常工作
- 滚动顶部不工作
- 滚动到顶部不工作的safari
- 平滑滚动到顶部不工作
- 平滑滚动到顶部不工作顺利
- 滚动顶部突然不工作的粘性菜单
- 页眉内的Div /靠近页面顶部/在2次点击事件后不显示,而它的's页脚双胞胎工作- jquery
- jQuery JS滚动到顶部的点击只工作一次
- 当想要滚动到顶部时,scrollTo不工作
- 滚动到页面的顶部(不工作在chrome)
- 回到顶部"元素,它与jQuery弹出窗口一起工作
- 滚动回顶部,在IE6中不工作
- 回到顶部按钮不工作在我的网站
- 文本框到页面顶部的过渡在IOS的Safari和Chrome上不能正常工作
- JavaScript在PHP页面的顶部不工作
- 只有顶部按钮向下滑动工作CSS jquery