我有一个RadGrid,它产生以下html(每行隐藏ID更改):
<input id="hiddenID" type="hidden" value="c6be9aaf-fc2b-441b-886e-120cfd6a73ee5" name="gvClaimDtSentDate$ctl00$ctl18$Detail50$ctl04$hiddenID">
<a id="c6be9aaf-fc2b-441b-886e-120cfd6a73ee" class="viewBtn" href="#">View</a>
<a class="orderBtn" id="lnkOrder" href="#">My Order</a>
我想点击lnkOrder获取原始的隐藏ID。所以我在下面做了但它不起作用,因为它给了我每行的静态/相同的id:
$('.orderBtn').click(function() {
var tr = $("#<%=gvDtSentDate.ClientID%> tr");
var id = tr.find("input[name$=hiddenID]").val();
有人可以帮忙吗。
答案 0 :(得分:1)
试试这个:
$('.orderBtn').click(function() {
var $tr = $(this).closest('tr'); // gets closest parent tr element to the a
var id = $tr.find("input[name$=hiddenID]").val();
// if hidden input is the only one in the row you could simplify this to:
// var id = $tr.find("input").val();
});