我正在try 打开与帖子相关的特定 comments ,但当我单击view more comments时,所有 comments 都会打开,但我想打开与帖子相关的 comments ,不是所有的,请帮助我如何解决?谢谢你
html view
<div class="comment-box">
@foreach ($communityPosts->communityPostReply as $communityPostReplies)
<div class="user-comment-box">
<div class="d-flex pt-3">
<div class="notification-text ms-3 w-100">
<span class="username fw-bold">{{$communityPostReplies->users->full_name}}</span>
<p class="mt-2 mb-0">{{$communityPostReplies->reply_body}}</p>
<span class="text-muted small">{{$communityPostReplies->created_at->diffForHumans()}}</span>
</div>
</div>
</div>
@endforeach
<a style="cursor: pointer;" class="see-more">View More Comments</a>
Here is my Jquery
$(function(){
$(".user-comment-box").slice(-5).show(); // select the first 5 hidden divs
$(".see-more").click(function(e){ // click event for load more
e.preventDefault();
var done = $('<div class="see-more=done"></div>');
$(".user-comment-box:hidden").slice(-5).show(); // select next 5 hidden divs and show them
if($(".user-comment-box:hidden").length == 0){ // check if any hidden divs
$(".see-more").replaceWith(done); // if there are none left
}
});
});