<table>
<tr onclick="GetIndexValue(this)">
<td>aaa</td>
</tr>
</table>function GetIndexValue(a){
    alert(a.rowIndex)   //行号
alert(a.childNodes[0].cellIndex) //列号
}
你的要的是列号,但你的函数在行里面,要注意下

解决方案 »

  1.   

    <table>
    <tr onclick="alert(this.rowIndex+'row')">
    <td onclick="alert(this.cellIndex+'cell')">aaa</td>
    <td onclick="alert(this.cellIndex+'cell')">aaa</td>
    <td onclick="alert(this.cellIndex+'cell')">aaa</td>
    </tr>
    <tr onclick="alert(this.rowIndex+'row')">
    <td onclick="alert(this.cellIndex+'cell')">bbb</td>
    <td onclick="alert(this.cellIndex+'cell')">bbb</td>
    <td onclick="alert(this.cellIndex+'cell')">bbb</td>
    </tr>
    <tr onclick="alert(this.rowIndex+'row')">
    <td onclick="alert(this.cellIndex+'cell')">ccc</td>
    <td onclick="alert(this.cellIndex+'cell')">ccc</td>
    <td onclick="alert(this.cellIndex+'cell')">ccc</td>
    </tr>
    <tr onclick="alert(this.rowIndex+'row')">
    <td onclick="alert(this.cellIndex+'cell')">ddd</td>
    <td onclick="alert(this.cellIndex+'cell')">ddd</td>
    <td onclick="alert(this.cellIndex+'cell')">ddd</td>
    </tr>
    <tr onclick="alert(this.rowIndex+'row')">
    <td onclick="alert(this.cellIndex+'cell')">eee</td>
    <td onclick="alert(this.cellIndex+'cell')">eee</td>
    <td  onclick="alert(this.cellIndex+'cell')">eee</td>
    </tr>
    </table>