2012-12-23 113 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