retrieving column header text

Posted on 2011-10-29
Last Modified: 2012-05-12
Hi , how to retrieve the text of a column header (<tr> <th> column name </th>.....'

when I click on a link inside  any <td> in that column ?
Question by:Rozamunda
    LVL 11

    Expert Comment

    Is there any distinquishing way to tell which column the link is in? Otherwise, you have to get all the TD's in the row and get the index of it and then select the TH with that index. I'll try and put something together.
    LVL 11

    Accepted Solution

    Tested it out here

    This should work:
    $(document).ready(function () {
        $('a.clicker').click(function() {
            var cell = $(this).parent();
            var index = $(this).closest('tr').children('td').index(cell);
            window.alert($('th:eq('+index+')', $(this).closest('table')).text());

    Open in new window


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now