我有一个评论部分,其中包含评论和回复。删除一条评论后,我也希望所有答复也被删除。我想到的唯一一种方法是使用此方法:
$(this).closest(".comment-container").next('.add-reply-container').next('.reply-comment-container')
我想在while
循环中执行此操作,直到删除所有答复,但是如何将动态.next('.reply-comment-container')
附加到我的对象上?
HTML
<div class="comment-container" id="number">
<div class="comment-title">
<span class="comment-creator-name"> Author Name </span> • now 2 minute
</div>
<div class="comment-text">
Question
</div>
<div class="comment-bottom">
<button class="comment-reply-button">Raspunde</button>
<button class="delete-comment-button">Sterge</button>
</div>
</div>
<div class="add-reply-container">
<textarea class="add-reply-textbox" placeholder="Scrie o intrebare..">
</textarea>
<button class="add-reply-button">Trimite</button>
</div>
<div class="reply-comment-container\">
<div class="comment-title">
<span class="comment-creator-name"> Reply Author Name </span> • now one minute
</div>
<div class="comment-text">
BLA BLA
</div>
</div>