菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> <style> table, td { border:1px solid black; } </style> </head> <body> <p>点击按钮弹出第一行第一个单元格的内容:</p> <table id="myTable"> <tr> <td>Row1 cell1</td> <td>Row1 cell2</td> </tr> <tr> <td>Row2 cell1</td> <td>Row2 cell2</td> </tr> <tr> <td>Row3 cell1</td> <td>Row3 cell2</td> </tr> </table> <br> <button onclick="myFunction()">点我</button> <script> function myFunction() { alert(document.getElementById("myTable").rows[0].cells.item(0).innerHTML); } </script> </body> </html>
运行结果