0
リストの番号を表示し、残りの番号をループする必要があります。リストを6つ表示し、残りの部分をスライスして戻るボタンをクリックします。もっと見るボタンのコメントを見る前のリストを表示して非表示にする
https://codepen.io/hesham-farag/pen/Ngadvj
<div class="comment-box-container">
<div class="comment-box">
<div class="user-comment-box">0</div>
<div class="user-comment-box">1</div>
<div class="user-comment-box">2</div>
<div class="user-comment-box">3</div>
<div class="user-comment-box">4</div>
<div class="user-comment-box">5</div>
<div class="user-comment-box">6</div>
<div class="user-comment-box">7</div>
<div class="user-comment-box">8</div>
<div class="user-comment-box">9</div>
<div class="user-comment-box">10</div>
<div class="user-comment-box">11</div>
<div class="user-comment-box">12</div>
<div class="user-comment-box">13</div>
<div class="user-comment-box">14</div>
<div class="user-comment-box">15</div>
<div class="user-comment-box">16</div>
<div class="user-comment-box">17</div>
<div class="user-comment-box">18</div>
<div class="user-comment-box">19</div>x">
<button class="see-more">See More...</button>
</div><!--comment-box end-->
</div><!-- comment-box-container end-->
.user-comment-box { display:none;
}
$(function(){
// select the first 5 hidden divs
$(".comment-box").each(function(index) {
$(this).children(".user-comment-box").slice(-5).show();
});
$(".see-more").click(function(e){ // click event for load more
e.preventDefault();
var done = $('<div class="see-more=done">done</div>');
$(this).siblings(".user-comment-box:hidden").slice(-5).show(); // select next 5 hidden divs and show them
if($(this).siblings(".user-comment-box:hidden").length == 0){ // check if any hidden divs
$(this).replaceWith(done); // if there are none left
}
});
});
ありがとう!
@Enivsionののthnxを検索するために、それはここでチェックし、HTTPSを動作しません://codepen.io/hesham-farag/pen/rwGjQo –
@HeshamFaragもっと明確にすることはできますか?何がうまくいきませんか?あなたは何を求めていますか? 今すぐショーをクリックすると、5つのリスト項目がリストに追加されます。追加するアイテムの数を変更するには、count + 3またはcount moreではなくshow functionを使用します。 – Etherealm
右私は私に5リストを表示し、Facebookのコメントのような過去を隠すだろう –