Homam
Homam

Reputation: 23841

How to select a table by a td's id

How to select a table by a td's id?

Upvotes: 1

Views: 2689

Answers (4)

wdm
wdm

Reputation: 7189

Use the closest() function.

$('#td-id').closest('table');

Demo: http://jsfiddle.net/LpPNA/1/

Upvotes: 2

Swaff
Swaff

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

zindel
zindel

Reputation: 1865

Try this out:

$('td#id').closest('table')

Upvotes: 1

Jon
Jon

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

Related Questions