我正在尝试使用 jQuery 插件Infinite-Scroll但没有成功。我的问题是插件不起作用,什么也没有发生,甚至是控制台错误,一切看起来都很好。我需要使用这个,因为我将使用另一个插件(jQuery Masonry),它支持并推荐 Infinite-Scroll。我很容易让 Masonry 工作,但不是 Infinite-Scroll。
所以我开始在一个测试页面中单独测试 Infinite-Scroll,但什么也没有。有什么帮助吗?
测试.html
<!DOCTYPE html>
<html>
<head>
<title>Infinite-Scroll Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="jquery.infinitescroll.min.js"></script>
<style>
#container {
width: 600px;
margin: 30px auto;
}
.element {
background: #666;
width: 100px;
height: 500px;
margin: 5px;
float: left;
}
</style>
</head>
<body>
<script>
$(function() {
var $container = $('#container');
$container.infinitescroll({
navSelector : '#page-nav', // selector for the paged navigation
nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
itemSelector : '.element', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.gif'
}
});
});
</script>
<div id="container">
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
<div class="element">
test
</div>
</div>
<nav id="page-nav">
<a href="next.html"></a>
</nav>
</body>
</html>
下一个.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="container">
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
<div class="element">
new one
</div>
</div>
</body>
</html>