本文實例講述了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操作DOM節點方法總結》、《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
新聞熱點
疑難解答