源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</title> <script> function cell(){ var x=document.getElementById('myTable').rows[0].cells; alert(x[0].innerHTML); } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>单元格 1</td> <td>单元格 2</td> </tr> <tr> <td>单元格 3</td> <td>单元格 4</td> </tr> </table> <br> <input type="button" onclick="cell()" value="第一个单元格"> </body> </html>
运行结果