0

別の画像ボタン(テーブルセル2内)をクリックすると、画像ボタン(テーブルセル1内)のIDを見つける必要があります。

javascript / jquery でインデックスをハードコーディングできません。

テーブルの特定の行内の 2 番目のボタンの ID を取得する他の方法はありますか?

助けてください

コードサンプル

<tr class="home-history-grid-row">
    <td>
        <img id="test" height="16px" width="16px" onclick="changeImage(this)" src="SiteImages/deleteconfirm.png" title="Confirm Delete" alt="Delete">
    </td>
    <td>
        <input id="ctl00_Content_NotificationHistory_ctl02_ImgDelete" type="image" style="height: 16px; width: 16px; border-width: 0px;" src="SiteImages/X.gif" clientidmode="Static" disabled="disabled" name="ctl00$Content$NotificationHistory$ctl02$ImgDelete">
    </td>
</tr>
4

3 に答える 3

1

あなたが正しく理解している場合は、画像をクリックして入力のIDを見つける必要がありますか? もしそうなら、これはあなたのためにそれをするでしょう:

function changeImage(self) {
    $(self).closest('tr').find('td input').attr('id');
}
于 2012-05-03T11:49:53.197 に答える
1
function changeImage(me){
  alert(me.id)
}
于 2012-05-03T11:45:46.257 に答える
0

次のコードで問題を解決する必要があります。

function changeImage(elm) {
    var otherImageId = $(elm).parent().next().find("input:first").attr("id");

    // ... use otherImageId here ...
}
于 2012-05-03T11:56:28.383 に答える