Reputation: 23841
How to select a table by a td's id?
Upvotes: 1
Views: 2689
Reputation: 7189
Use the closest() function.
$('#td-id').closest('table');
Demo: http://jsfiddle.net/LpPNA/1/
Upvotes: 2
Reputation: 13621
Using jQuery closest
Using the following example code
<table id="test">
<tr>
<td id="one">one</td>
</tr>
</table>
<table>
<tr>
<td id="two">two</td>
</tr>
</table>
$(document).ready(function(){
var table = $("#one").closest('table');
});
See example here
Upvotes: 2
Reputation: 437376
You probably want something like
$("#myId").closest("table");
but I 'm not completely sure -- can you clarify or provide an example?
Upvotes: 5