0

次のhtml(行ごとに非表示のID変更)を生成するRadGridがあります。

<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のクリックでrawの非表示IDを取得したい。だから私は以下を行いましたが、それは私に各行の静的/同じIDを与えるので機能しません:

$('.orderBtn').click(function() {

            var tr = $("#<%=gvDtSentDate.ClientID%> tr");
            var id = tr.find("input[name$=hiddenID]").val();

誰か助けてくれませんか。

4

1 に答える 1

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();
});
于 2013-01-14T15:06:42.137 に答える