×

jQuery实现查找最近父节点的方法

作者:ceshi2017.04.17来源:Web前端之家浏览:12730评论:0
关键词:JQueryJS

本文实例讲述了jQuery实现查找最近父节点的方法。分享给大家供大家参考,具体如下:

这里演示查找当前控件最近的table

<html>
  <head>
    <title>usually function</title>
  </head>
  <body>
    <table name="name_table1">
      <tr>
        <td>table1</td>
      </tr>
    </table>
    <table name="name_table2">
      <tr>
        <td>table2</td>
      </tr>
    </table>
    <table name="name_table3">
      <tr>
        <td>table3</td>
      </tr>
    </table>
  </body>
<html>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script>
$(function(){
  $("td").bind("click",function(){
    //alert($(this).html());
    alert($(this).closest("table").attr("name"));
  });
});
</script>

您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/biji62.html

网友评论文明上网理性发言 已有0人参与

发表评论: