fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.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>
运行结果