JQuery - 滚动功能不起作用

时间:2014-05-26 06:58:23

标签: jquery scroll

我想用jquery在页面滚动上显示circlefull动画,但是没有一个滚动功能可以工作。

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

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'>    </script>

<script type="text/javascript">
$(document).ready( function (){
      alert('ready');
$('#htmlbody').scroll( function (){
      alert('scroll'); 
});
});
</script>

没有人工作。有什么问题?任何错误都不会在控制台中登录。

1 个答案:

答案 0 :(得分:0)

$('#htmbody')错了。

使用此:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){
    $(window).scroll(function(){
        alert('scroll'); 
    });
});
</script>

演示:

http://jsfiddle.net/wqZ6G/

如果您想致电HTMLBODY动画滚动顶部使用:

$('html, body').animate({scrollTop:'400px'},{duration:1000});

演示:

http://jsfiddle.net/wqZ6G/1/

相关问题