<script type="text/javascript">
alert(document.getElementById('td1').cellIndex);
alert(document.getElementById('td2').cellIndex);
<td id="td2">Griffin</td>
<input type="button" onclick="alertTd1()" value="Alert cell index of 'Peter'" />
<input type="button" onclick="alertTd2()" value="Alert cell index of 'Griffin'" />