in that case, you could give each respond div a unique ID, and then each anchor tag place the id of the respond div it needs to open in the anchor's href, such as:
- <a href="#respond-1" class="leavecomment">Reply</a>
- <div id="comments">COMMENTS</div>
- <div id="respond-1" style="display:none;">blah</div>
- <a href="#respond-2" class="leavecomment">Reply</a>
- <div id="comments">COMMENTS</div>
- <div id="respond-2" style="display:none;">blah</div>
- <a href="#respond-3" class="leavecomment">Reply</a>
- <div id="comments">COMMENTS</div>
- <div id="respond-3" style="display:none;">blah</div>
then use:
- $('.leavecomment').click(function(e){
- $($(this).attr('href')).toggle();
- })