I have a scenario like
<table>
<thead>
<tr>
<th id ="myid1">header1</th>
<th id ="myid2">headre "2</th>
<th id ="myid3">header3</th>
</tr>
</thead>
<tr>
<td>v1</td>
<td>v2</td>
<td>v3</td>
</tr>
<tr>
<td>v10</td>
<td>v11</td>
<td>v12</td>
</tr>
<tr>
<td>v20</td>
<td>v21</td>
<td>v22</td>
</tr>
<tr>
<td>v30</td>
<td>v31</td>
<td>v32</td>
</tr>
</table>
there can be thousands of row .
i need to get the id of the td on which that perticulat td belongs to.
for example . if i click the third td of third row .. i should get the id of corresponding th , here it is myid3 (here its hard coded but it will set based on the value from server side)
$('tbody td').live('click', function() {
var idOfTh = ??
});
Working JSfiddle: http://jsfiddle.net/6etRb/
You only need to use live delegation if the table rows are being added dynamically, and in that case you should use
.on()as described by others.