这是我目前的代码:
$('.list-request-negotiating-loadmore').on('click', function(){
$(".request-negotiating-item:hidden").slice(0, 3).show();
if($(".request-negotiating-item:hidden").length < 3){
$('.list-request-negotiating-loadmore').hide();
}
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="dashboard-info list-requests request-negotiating" >
<div class="enquiry request-item request-negotiating-item" >1</div>
<div class="enquiry request-item request-negotiating-item" >2</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">3</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">4</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">5</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">6</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">7</div>
</div>
<div class="dashboard-title list-request-negotiating-loadmore loadmore" style="">load more</div>
&#13;
如果隐藏的div少于3个,我希望隐藏loadmore
按钮,但由于某些原因我的代码无法正常工作。
答案 0 :(得分:0)
您的代码似乎有效,但从用户体验来看,您不希望有更接近此的内容
esp
&#13;
$('.list-request-negotiating-loadmore').on('click', function(){
$(".request-negotiating-item:hidden").slice(0, 3).show();
if($(".request-negotiating-item:hidden").length < 1){
$('.list-request-negotiating-loadmore').hide();
}
});
&#13;