if I had to do this, I would make it a lot easier, as shown below:
HTML:
{% for comment in comments %} <div id="{{comment.id}}"> // this div will separate each iterate elements <a href="#">Reply</a> // no inline method required in jquery <form name="titleform" action="/{{slug}}/reply/" method = "post"> <input type="hidden" name="id" value="{{comment.id}}"/> <textarea name = "comment" value="" rows="7" cols="50"></textarea><br> <input type="submit" value="Submit"/> </form> </div> {% endfor %}
JQuery
$('a').click(function(){ $(this).next('form').toggle(); });
script: http://jsfiddle.net/VjthL/2/
source share