【发布时间】:2011-08-25 19:26:33
【问题描述】:
这是我的 Django 模板:
{% for feed in feeds %}
<div id="feed"><b>At {{feed.location}}:<b> {{feed.msg}}</b></div></br>
<button id="bb{{feed.id}}">Add Comment</button>
<div id="commentbox" style="display:none;">
<form method="post" action="/comment/{{feed.id}}/">
{{cform.as_p}}
<input type="submit" value="comment" />
</form>
</div>
{% endfor %}
jquery代码在这里:
<script>
$(function() {
$("#bb.").click(function () {
$("#commentbox").toggle("slow");
});
});
</script>
但这里只有第一个 div 在 for 循环内切换。 Jquery 不适用于剩余的 for 循环元素。你能给我正确的jQuery代码吗?谢谢。
【问题讨论】:
-
任何给定的 id 都不应该有多个元素。 ID 应该是唯一的;重复它们只是自找麻烦。
-
我已经更改了 ID,但我的概率相同。帮助。
标签: jquery python django jquery-selectors django-templates