Returning the Name of a column header
- by Jason Kelly
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>