首页  >  文章  >  web前端  >  jQuery实现查找最近父节点的方法

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

韦小宝
韦小宝原创
2017-11-29 10:18:112733浏览

本文实例讲述了jQuery实现查找最近父节点的方法,对于jQuery不太熟的同学们,我们一起来学习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>

以上就是jQuery实现查找最近父节点的方法,更多jQuery相关的内容请在本站进行搜索哦~

相关推荐:

JQuery节点元素属性操作方法_jquery

JQuery中选择器与DOM节点操作的实例详解

jQuery中DOM操作实例分析

以上是jQuery实现查找最近父节点的方法的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn