Jquery代码在IE和Firefox上无法正常工作

3

我写了一段小的jQuery代码,在Chrome和Opera上可以正常运行,但在IE和Firefox上无法正常工作。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js">
$(document).scroll(function () {
    if ($('body')[0].scrollTop / $('body')[0].scrollHeight > 0.29) {
     $(".over_one").fadeIn(2000);
    } else {
     $(".over_one").fadeOut(1);
    }
   });
</script>

I have also searched here and here, but this was not fixing my problem.


你尝试过使用相当的jQuery方法来访问那些属性吗?不是所有浏览器都支持scrollHeight。 - iCollect.it Ltd
1
浏览器使用不同的元素进行滚动。有些使用 html,其他使用 body。你的代码看起来可能会受到影响,除了 @Filype 发现的问题之外。(尽管“不工作”是一种比较模糊的错误描述,因为我们不知道你想要实现什么。) - Boldewyn
我解决了,大家好,我已经将 'html, body' 添加到 .scrollHeight 中并删除了 .scrollTop,感谢 @Boldewyn、@TrueBlueAussie 和 @Filype 的帮助。 - mishad050
1个回答

1
我认为你在

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接