Here is my Django template:
{% 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 code is here:
<script>
$(function() {
$("#bb.").click(function () {
$("#commentbox").toggle("slow");
});
});
</script>
But here only the first div toggles inside the for loop. Jquery does not work for the remaining for loop elements. Can you please give me the proper jQuery code. Thanks.
make this change:
and this one:
Update:
And here is a working demo.