[英]JQuery scrolling not working in Internet Explorer or Firefox
我正在使用一些JQuery在當前正在構建的新視差滾動網頁上顯示/隱藏一些操作按鈕。 滾動過去100像素后,它將顯示操作按鈕。 如果向上滾動,操作按鈕將消失。
它可以在Chrome中完美運行,但不能在Firefox或Internet Explorer中運行。 我在頁面上使用其他JQuery,並且在Firefox和Internet Explorer中正確觸發。
這是有問題的代碼:
$(document).ready(function () {
slider();
});
$(window).scroll(function () {
slider();
});
function slider() {
if (document.body.scrollTop > 100)
$('#request').stop().animate({"bottom": '10'});
else
$('#request').stop().animate({"bottom": '-75'});
}
經過進一步研究后,我發現Firefox和IE識別“頂部”的方式有所不同,因此我將代碼更改為:
if (document.body.scrollTop > 100)
至:
if ($(window).scrollTop() + 1 > 100)
和代碼完美地工作!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.