【发布时间】:2014-04-06 18:14:51
【问题描述】:
我在一页上有多个评论表单,在 ajax 调用后需要将评论附加到 cmetsholder div。但目前它把它添加到所有,不知道如何只将它添加到当前的 div。
所以 cmets 部分如下所示:
<div class="commentson">
<div class="commentsholder"> All THE COMMENTS IN HERE </div>
<form class="addcomment" action="process/addcomment.php" method="post">
<div class="commentbutton">
<input type="text" maxlength="250" name="addpostcomment" class="addpostcomment" placeholder="Add Comment... (max 60 characters)" />
<input type="submit" id="addcommentbutton" class="addcommentbutton" value="Post" disabled/>
</div>
<span class="countdownCommentLength"></span>
</form>
</div>
jQuery 追加:
$( ".commentsholder" ).append("New Comment");
cmets div 内还有其他形式等,但我需要做的只是将注释附加到当前使用的 cmetson div 中的 cmets 持有人。
【问题讨论】:
-
你的整个 html 结构是什么样的?
-
什么决定了“当前的 div”
-
刚刚用完整的 html 更新了问题。我所说的当前 div 是指包含已提交表单的 div。
标签: javascript jquery html ajax append