Home > Article > Web Front-end > jQuery implements the method of finding the nearest parent node
The example of this article describes the method of jQuery to find the nearest parent node. For students who are not familiar with jQuery, let’s learn jQuery together!
Here is a demonstration of finding the nearest table code of the current control:
<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>
The above is how jQuery implements finding the nearest parent node. For more jQuery-related content, please visit this site Search~
Related recommendations:
##JQuery node element attribute operation method_jquery
Detailed examples of selector and DOM node operations in JQuery
Analysis of examples of DOM operations in jQuery
The above is the detailed content of jQuery implements the method of finding the nearest parent node. For more information, please follow other related articles on the PHP Chinese website!