0

嘿伙计们,我正在尝试实现 onscroll 功能,但它在我的网站上不起作用。

我究竟做错了什么?

<head>
<script>
$(document).ready(function() {

/* Every time the window is scrolled ... */
$(window).scroll( function(){

/* Check the location of each desired element */
$('.hideme').each( function(i){

var bottom_of_object = $(this).position().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();

 /* If the object is completely visible in the window, fade it it */
 if( bottom_of_window > bottom_of_object ){

 $(this).animate({'opacity':'1'},500);

 }

 }); 

 });

});</script>
</head>

<body>

<div id="container">

<div class="hideme">Fade In</div>
<div class="hideme">Fade In</div>
<div class="hideme">Fade In</div>
<div class="hideme">Fade In</div>
<div class="hideme">Fade In</div>

</div>
</body>

并链接到该站点以获取完整代码: http ://eren-web-design-development.tk/C-Html/landingpage/

4

2 回答 2

0

我看到了错误

TypeError: $(...).ready is not a function

在我的控制台中。我认为 $ 与您代码中的其他一些库冲突。无论如何,试试这个并检查它是否有效:

jQuery(document).ready(function($) {
..

}
于 2014-09-26T13:59:05.907 回答
0

我查看了您的网站并认为问题出在您的 jQuery 上。它可能没有正确加载。

$ 已定义。但是当我做 $("html") 它返回null。当我使用 jQuery("html") 它确实返回正确。

其他东西正在占用 $ 变量。

于 2014-09-26T14:00:03.170 回答