Here is one way - it will find the header (th) for any cell (td) given
that there are no merged cells and a single header row.

$('td').click(function(){
   var col = $(this).prevAll().length;
   var headerObj = $(this).parents('table').find('th').eq(col);

   // A quick test!
   alert("My cell header is called: " + headerObj.text());
});

On Apr 8, 3:56 pm, "R. Rajesh Jeba Anbiah"
<[EMAIL PROTECTED]> wrote:
> I'm just wondering if there is any easy way to find out the header
> (th) of the table column (td)?
> Say,
> ----------------------
> | head1 | head2 |
> ----------------------
> | r11     |  r12     |
> ----------------------
> | r21     |  r22     |
> ----------------------
>
>      Here, r22's heading is "head2"
>
> --
>   <?php echo 'Just another PHP saint'; ?>
> Email: rrjanbiah-at-Y!com    Blog:http://rajeshanbiah.blogspot.com/

Reply via email to