1

我试图一次显示 5 个滑块,这样当您单击“加载更多”按钮时,将显示 5 个以上。我也不想要警报,我只想让负载消失。不幸的是,我所有的滑块都保持隐藏状态,并且按钮不起作用。这就是我所拥有的...

在我的 CSS 中:

.container {
display: none;
}

我的 HTML 是 15 个带有滑块的 div,底部是加载更多按钮:

<div class="container"></div>
<a href="#" id="load">Load More</a>​

我的jQuery是:

$(window).load(function() {
$(".container").slice(0, 5).show(); // select the first five
$("#load").click(function(e){ // click event for load more
    e.preventDefault();
    $("container:hidden").slice(0, 5).show(); // select next 5 hidden divs and show them
    if($(".container:hidden").length == 0){ // check if any hidden divs still exist
        alert("No more divs"); // alert if there are none left
    }
});

});​</p>

4

1 回答 1

0

If container is holding all of the information you want, then nowhere are you changing it's css to be anything but display:none. This means that no matter what content is in there, nothing is going to be shown. And if you do not want the alert, just delete it? I don't quite understand that part.

于 2012-08-16T20:32:20.230 回答