<TABLE id=tbl cellSpacing=1 cellPadding=1 border=1>
<TBODY>
<TR>
<TD width=100>This is Line1</TD></TR>
<TR>
<TD width=100>This is Line2</TD></TR>
<TR>
<TD width=100 onclick="alert(this.parentElement.cellIndex)">This is Line3</TD></TR>
</TBODY>
</TABLE>

解决方案 »

  1.   

    不好意思
    写错了
    <TABLE id=tbl cellSpacing=1 cellPadding=1 border=1>
    <TBODY>
    <TR>
    <TD width=100>This is Line1</TD></TR>
    <TR>
    <TD width=100>This is Line2</TD></TR>
    <TR>
    <TD width=100 onclick="alert(this.cellIndex)">This is Line3</TD></TR>
    </TBODY>
    </TABLE>
      

  2.   

    obj.rowIndex是行号
    obj.cellIndex是列号
      

  3.   

    谢谢各位!
    在请问大家一下,为什么用,obj.focus()获得焦点时,文本框中的内容不会被选中,请问如何处理后才能让它被选中。
    谢谢!
      

  4.   

    obj.focus()获得焦点时,文本框中的内容不会被选中,请问如何处理后才能让它被选中
    -----------------<input type="text" onfocus="this.select()" value="灰豆宝宝.net">
      

  5.   

    谢谢!
    列总数能直接得到吗?
    还是要通过the_table.cells.length和the_table.rows.length来计算?
    好象是不能用the_table.cols.length.
    谢谢!
      

  6.   

    <table border> 
    <tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr> 
    <tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr> 
    <tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr> 
    <tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr> 
    <tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr> 
    </table> 
    <script> 
    function document.onclick(){ 
    var e=window.event.srcElement 
    if(e.tagName=="TD"){ 
    window.status="第"+(e.parentElement.rowIndex+1)+"行,第"+(e.cellIndex+1)+"列" 


    </script>
      

  7.   

    <table border=1 onclick="alert(this.rows[0].cells.length)">
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    </tr>
    </table>
      

  8.   

    <table border=1 onclick="alert(getColsLength(this))">
    <tr>
    <td colspan=2>12</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    </tr>
    </table>
    <script>
    function getColsLength(tbObj){
    var count=tbObj.rows[0].cells.length;
    for(var i=0;i<tbObj.rows[0].cells.length;i++){
    count+=parseInt(tbObj.rows[0].cells[i].colSpan,10)-1;
    }
    return count;
    }
    </script>