[英]Jquery/Javascript not working on Firefox. Why?
I just found out that my script is working fine in Chrome, but not in FireFox - and I can't figure out why. 我刚刚发现我的脚本在Chrome中可以正常运行,但在FireFox中却无法正常工作-我不知道为什么。
This is the site in development: www.fireflycovers.com 这是开发中的网站: www.fireflycovers.com
The script should execute when one of the round green buttons is clicked. 单击圆形绿色按钮之一时,脚本应执行。 (scrolls the window to the next container)
(将窗口滚动到下一个容器)
The script looks like this at the moment: 此刻脚本如下所示:
$('.scroll').css('display' , 'block');
$('.scroll').on('click', function(e) {
var container = $(this).parent();
// Scans if last container in group
while (document != container[0] &&
container.find('~.col, ~:has(.col)').length == 0) {
// If so, search siblings of parent instead
var container = container.parent(),
nextdiv = container.nextAll('.col, :has(.col)').first();
}
// Back to first .col (when no next .col)
if (nextdiv.length == 0) {
nextdiv = $(document).find('.col:first')
};
// Animates scrolling to new position
$('body').animate({scrollTop:nextdiv.offset().top}, 1000);
return false;
});
});
Did you try debugging at all? 您是否尝试过调试? As in, putting
console.log
statements throughout your method to see what the values of things are at certain times and watching it execute? console.log
在整个方法中放置console.log
语句以查看特定时间的事物值并观察其执行情况? Anyway, does using this help at all? 无论如何,使用此功能是否有帮助?
$('body,html').animate({scrollTop:nextdiv.offset().top}, 1000);
Verified from Animate scrollTop not working in firefox 从Animate scrollTop验证无法在Firefox中使用
You need html
because firefox behaves differently when it comes to overflow
. 您需要
html
因为在发生overflow
时,Firefox的行为有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.