jQuery - <li> 通过 $(this) 访问层次结构中的父级五级



我有一个嵌套结构:

<li id="RCL137_1" class="rcl137">
  <table>
    <tbody>
       <tr>
          <td>
             <img id="RCDEL137_1" class="icon_rcdel" src="images/icon_delete.png">

如果图像是 $(this),有没有一种简单的方法可以在不使用 ID 的情况下引用它所属的行? (比如,家长李某事...我可以通过parent().parent()...但必须有一种更整洁的方法。

顺便说一句:我一直在按 ID 执行此操作,但我想添加一个类似于以下内容的类事件处理程序:

$('#container').on('click', '.icon_rcdel', function (e) {
    $(this). [navigate to li] .remove();

谢谢。

$(this).closest('li').remove();

见 http://api.jquery.com/closest/

和 http://api.jquery.com/find/

最新更新