Returning the Name of a column header
Posted
by
Jason Kelly
on Stack Overflow
See other posts from Stack Overflow
or by Jason Kelly
Published on 2012-10-22T16:58:43Z
Indexed on
2012/10/22
17:00 UTC
Read the original article
Hit count: 191
I need your help,
Given the html table below, how can I create a javascript function that will, at the click of a mouse, alert me the name of the column header?
Ie. if I click on the COLORS header, a javascript box will popup and alert("COLORS")?
<html>
<head>
</head>
<body>
<table border="1" cellspacing="1" width="500">
<tr>
<td>FRUITS</td>
<td>COLORS</td>
<td>VEGGIES</td>
<td>NUMBERS</td>
</tr>
<tr>
<td>apples</td>
<td>red</td>
<td>carrots</td>
<td>123</td>
</tr>
<tr>
<td>oranges</td>
<td>blue</td>
<td>celery</td>
<td>456</td>
</tr>
<tr>
<td>pears</td>
<td>green</td>
<td>brocoli</td>
<td>789</td>
</tr>
<tr>
<td>mangos</td>
<td>yellow</td>
<td>lettuce</td>
<td>098</td>
</tr>
</table>
</body>
</html>
© Stack Overflow or respective owner