The easiest way would be to get the position (index) of the header in the row and then access all cells with the same column index.
$('#table th').click(function() { var th = $(this); var index = $('th', th.parents('tr')).index(th); var column = $('tbody td:nth-child(' + (index + 1) + ')', th.parents('table')); var values = column.map(function() { return $(this).text(); }); alert($.makeArray(values)); });
Based on this example:
<table id="table"> <thead> <tr><th>head1</th><th>head2</th><th>head3</th></tr> </thead> <tbody> <tr><td>cell1a</td><td>cell2a</td><td>cell3a</td></tr> <tr><td>cell1b</td><td>cell2b</td><td>cell3b</td></tr> <tr><td>cell1c</td><td>cell2c</td><td>cell3c</td></tr> </tbody> </table>
source share