私は次のようなHTML構造を持っています:
<tr class = "@rowOrdinal" id = "...">
<td>
<a href = "#">
<img src = "/Content/updateIcon.gif" class = "updateResourceImageButton" id = "..." />
</a>
<a href = "#">
<img src = "/Content/cancelIcon.gif" class = "cancelImageButton" />
</a>
</td>
<td class = "hiddenColumn" id = ...>...</td>
<td class = "resourceKeyColumn" id = ...>...</td>
... and so on...
tr
更新リンクをクリックすると、行への参照、つまり更新ハイパーリンクがあった要素を取得したいと思います。
したがって、以下のイベント リスナーでは、DOM 階層を数レベル上に移動したいと思います。単純な JavaScript を使用し、while
ループを使用して を取得することもできparentNode
ますが、jQuery でそれを行うにはどうすればよいでしょうか?
function WireHandlers() {
$('.updateResourceImageButton').click(UpdateResourceLinkClickedHandler);
}
function UpdateResourceLinkClickedHandler() {
// how do I get a reference to the tr that contains
// the hyperlink which is the source of this event?
}
$(document).ready(function () { WireHandlers(); });