【发布时间】:2011-09-30 09:07:05
【问题描述】:
我正在尝试获取链接点击事件的隐藏字段值。以下是这些元素所在的位置:
<p>
<a class="showCommentAttachment cboxElement" href="#">Attachments</a>
<input type="hidden" value="13" id="ctl00_ContentPlaceHolder1_lvComment_ctrl3_hfCommentId" name="ctl00$ContentPlaceHolder1$lvComment$ctrl3$hfCommentId">
</p>
这里是完整的标记:
<div id="divComment" class="comment-text">
<div class="comment-author">
David Chart
</div>
<span class="comment-date-time">Sep 29, 2011 08:12:42 PM</span>
<p>
Some comment text goes here. Some comment text goes here.
</p>
<p>
<a class="showCommentAttachment cboxElement" href="#">Attachments</a>
<input type="hidden" value="13" id="ctl00_ContentPlaceHolder1_lvComment_ctrl3_hfCommentId" name="ctl00$ContentPlaceHolder1$lvComment$ctrl3$hfCommentId">
</p>
</div>
这里是 jQuery:
$("#divComment a.showCommentAttachment").click(function() {
var nextSibling = $(this).next().find('input:hidden').val();
$("#showCommentId").html(nextSibling + "<-- Here's the comment ID ");
});
我从 nextSibling 得到的结果是未定义的。我试过这样的nexAll
var nextSibling = $(this).nextAll().find('input:hidden').val();
仍然未定义。
谢谢。
【问题讨论】:
标签: jquery