jQuery在while循环中点击淡出隐藏元素


jQuery on click fade in hidden element in while loop

我有一个表单在while循环激活,当我点击Reply按钮。这我可以做得很简单,但它在while循环中,需要一个唯一的ID。我的代码工作到现在,但它只适用于第一个结果。当我点击其他结果时,什么也没有发生。即使我已经分配了一个唯一的ID,它不工作。我的代码如下:

jQuery部分:

$(document).ready(function() {
    $("#reply").on('click', 'a.click', function() {
        var rowid = $(this).attr("data-rowid");
        $(".reply-comment-holder[data-rowid='" + rowid + "']").fadeToggle(800),
        $(this).toggleClass(".reply-comment-holder[data-rowid='" + rowid + "']");
    });
});
HTML部分:
 <?php while($fetch_cmts = $get_cmtq->fetch()){ extract($fetch_cmts); ?>
    <div id="reply"><a href="javascript:;" data-rowid="<?php echo $cmt_id?>" class="click show-reply-box">Reply</a></div>
    <div class="reply-comment-holder" data-rowid="<?php echo $cmt_id?>" style="display:none;">
              <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="full-width cmtform" id="cmt_form_id_<?php echo $cmt_id?>">
                <input type="hidden" name="status_id" value="<?php echo $cmt_id; ?>" id="cmtsid_<?php echo $cmt_id?>" />
                <textarea name="comment" placeholder="Give a reply..." class="reply-comment-field commentarea" id="replycomment_<?php echo $cmt_id?>"></textarea>
              </form>
            </div>
<?php } ?>

HTML

<div class="reply"><a href="javascript:;" data-rowid="1" class="click show-reply-box">Reply</a></div>
<div class="reply-comment-holder" data-rowid="1" style="display:none;">
          <form method="post" action="#" class="full-width cmtform" id="cmt_form_id_1">
            <input type="hidden" name="status_id" value="1" id="cmtsid_1" />
            <textarea name="comment" placeholder="Give a reply..." class="reply-comment-field commentarea" id="replycomment_1"></textarea>
          </form>
        </div>
<div class="reply"><a href="javascript:;" data-rowid="2" class="click show-reply-box">Reply</a></div>
<div class="reply-comment-holder" data-rowid="2" style="display:none;">
          <form method="post" action="#" class="full-width cmtform" id="cmt_form_id_2">
            <input type="hidden" name="status_id" value="2" id="cmtsid_2" />
            <textarea name="comment" placeholder="Give a reply..." class="reply-comment-field commentarea" id="replycomment_2"></textarea>
          </form>
        </div>  
javascript

$(document).ready(function() {
    $(".reply").on('click', 'a.click', function() {
        var rowid = $(this).attr("data-rowid");
        $(".reply-comment-holder[data-rowid='" + rowid + "']").fadeToggle(800),
        $(this).toggleClass(".reply-comment-holder[data-rowid='" + rowid + "']");
    });
});

jsbin列在上面的注释中