您可以将所有div设置为display:none;首先,然后使用jQuery显示前10个(或者你想要显示多少个):
$(function(){
$("div").slice(0, 10).show(); // select the first ten
$("#load").click(function(e){ // click event for load more
e.preventDefault();
$("div:hidden").slice(0, 10).show(); // select next 10 hidden divs and show them
if($("div:hidden").length == 0){ // check if any hidden divs still exist
alert("No more divs"); // alert if there are none left
}
});
});
这可以节省您在几行代码中实现所需内容时包含整个插件的麻烦.