【转】jquery 中scrollTop在Firefox下不起作用
2016-01-13 17:34
567 查看
原文链接:http://stackoverflow.com/questions/8149155/animate-scrolltop-not-working-in-firefox
Animate scrollTop not working in firefox
up vote 115 down vote favorite 21 | This function works fine. It scrolls the body to a desired container's offsetfunction scrolear(destino){ var stop = $(destino).offset().top; var delay = 1000; $('body').animate({scrollTop: stop}, delay); return false; } But not in Firefox. Why? -EDIT- To handle de double trigger in the acepted answer, I suggest stoping the element before the animation: $('body,html').stop(true,true).animate({scrollTop: stop}, delay); |
10 Answers
active oldest votesup vote 240 down vote accepted | Firefox places the overflow at the htmllevel, unless specifically styled to behave differently. To get it to work in Firefox, use $('body,html').animate( ... ); Working example The CSS solution would be to set the following styles: html { overflow: hidden; height: 100%; } body { overflow: auto; height: 100%; } I would assume that the JS solution would be least invasive. |
相关文章推荐
- JQuery总结:选择器归纳、DOM遍历和事件处理、DOM完全操作和动画
- Jquery的一些知识点
- jquery悬浮提示框完整实例
- js和jquery实现监听键盘事件示例代码
- jQuery.extend 函数详解
- jQuery简单操作cookie的插件实例
- chrome浏览器下用jQuery的load函数来跨域加载页面,响应状态status为(canceled)是什么情况? JSON和JSONP,也许你会豁然开朗,含jQuery用例
- Jquery控制文本框只能输入数字或字母
- JQuery之Ajax请求
- jquery判断checkbox最多选几个
- JQuery实现点击div里面的a的能触发点击时间,但是不触发外面的div的点击事件
- jquery.cookie中的操作
- jquery:选择器 过滤器
- JSON+Jquery省市区三级联动
- jquery操作radio,checkbox
- jQuery计算时间差和阴阳历转换
- jquery验证(产品三期-院历增加)
- jQuery遍历函数
- JQuery中$.ajax()方法参数详解
- jQuery选择器