2012-12-23 111 views
2

我剛開始使用jQuery製作滑動菜單,但沒有一個滾動功能可以工作。 JQuery連接(我檢查)。我試圖在Chrome瀏覽器中玩遊戲機,我得到的是JQuery滾動功能不起作用

> $("body").scrollTop(); 
    0 
> $(window).scrollTop(); 
    0 

這很有趣,這些函數的返回值總是等於零! 或者例如我試圖使用scroll()函數來綁定頁面滾動...它不起作用。

$(window).scroll(function(){ 
    alert('Its scrolling!'); 
}); 

或驗證碼

$(window).bind('scroll', function(){ 
    alert('And its scrolling TOO!'); 
}); 

沒有一部作品。有什麼問題? 任何錯誤也不會記錄在控制檯中。

我的網站是http://q-2.su

回答

0

我發現這個在您的網頁(您提供的網址):

$(document).ready(function(){ 
    console.log('ready'); 
    $('.wrapper').scroll(function(){ 
    //-^------------------------------------here you are refering to the class but in 
     console.log('scroll'); // ----------you used id 
    }); 
}); 

所以這將是:

$(document).ready(function(){ 
    console.log('ready'); 
    $('#wrapper').scroll(function(){ 
    //-^------------------------------------here you have to use # for id 
     console.log('scroll'); 
    }); 
}); 
+0

OMG,我不知道,我很愚蠢:)非常感謝你) – impulsgraw