?
Solved

retrieving column header text

Posted on 2011-10-29
2
Medium Priority
?
286 Views
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 ?
0
Comment
Question by:Rozamunda
  • 2
2 Comments
 
LVL 11

Expert Comment

by:MacAnthony
ID: 37051648
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.
0
 
LVL 11

Accepted Solution

by:
MacAnthony earned 2000 total points
ID: 37051686
Tested it out here http://jsfiddle.net/MacAnthony/K7yTf/

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

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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 the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

839 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