Q:

Jquery, get columname when cell clicked

How can I get column name with Jquery when any cell is clicked?

A:

You can do it by obtaining the index of the cell, and then getting the text from the header with the same index.
I have uploaded a demo here:
http://jsfiddle.net/Sohnee/DNxTz/23/
The jQuery looks like this:
$("td").click(function(){
    var $This = $(this);
    var col = $This.parent().children().index($(this));
    var title = $This.closest("table").find("th").eq(col).text();
    alert(title);
});

And relies on a proper table structure....
<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Address</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Steve</td>
            <td>UK Somewhere</td>
        </tr>
        <tr>
            <td>Scott</td>
            <td>USA Somewhere</td>
        </tr>
    </tbody>
</table>

Note: caption, tfoot et al, omitted optional stuff can all be added and the script still works.
http://www.w3.org/TR/html401/struct/tables.html

