W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <script> function getCellContent(id) { var x = document.getElementById(id).rows[0].cells; document.getElementById("demo").innerHTML = x[0].innerHTML; } </script> </head> <body> <table id="myTable" style="border: 1px solid black"> <tr> <td>cell 1</td> <td>cell 2</td> </tr> <tr> <td>cell 3</td> <td>cell 4</td> </tr> </table> <p> <input type="button" onclick="getCellContent('myTable')" value="显示第一个单元格"> </p> <p id="demo"></p> </body> </html>