jquery - 如何将动态 .next() 函数附加到 jQuery 对象
问题描述
我有一个带有评论和回复的评论部分。删除一条评论后,我希望也删除所有回复。我想到的唯一一种方法是使用这个:
$(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>
解决方案
推荐阅读
- ios - 如何阻止 segue 在 Swift 中以编程方式进行?
- java - Heroku Java Gradle 应用程序在线程“main”java.lang.NoClassDefFoundError 中崩溃并出现异常:io/reactivex/rxjava3/core/ObservableSource
- swift - 如何解析 CSV 文件,以便 tableView 可以轻松访问它?
- discord.py-rewrite - 如何检查 discord.py 中的反应内容?
- python - 在 python (2020) 中并行化 for 循环的最佳方法是什么?
- javascript - 使用 Jsoup 登录时如何处理 Input 标签中缺少 name 属性?
- ruby-on-rails - 如何在 WINDOWS 10 上将 rails 从 rails 6 降级到 5.2.3?
- git - 了解 git diff 的作用
- mysql - MySQL timediff 函数没有给出正确的输出
- spring-boot - Springdoc:打开 swagger-ui.html 时得到 404