导航首页 » 技术教程 » jQuery实现查找最近父节点的方法
jQuery实现查找最近父节点的方法 77 2024-02-27   

本文实例讲述了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="http://www.gimoo.net/t/1902/jquery-1.4.4.js"></script>
<script>
$(function(){
  $("td").bind("click",function(){
    //alert($(this).html());
    alert($(this).closest("table").attr("name"));
  });
});
</script>

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery操作DOM节点方法总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jQuery表格(table)操作技巧汇总》、《jquery中Ajax用法总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。



!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103