示例您可以尝试运行以下代码以了解如何删除表中的行。该代码一次删除一行 -
现场演示
<!doctype html><html> <head> <script> function captionfunc(x) { document.getelementbyid(x).createcaption().innerhtml = "demo caption"; } </script> </head> <body> <table style="border:2px solid black" id="newtable"> <tr> <td>one</td> <td>two</td> </tr> <tr> <td>three</td> <td>four</td> </tr> <tr> <td>five</td> <td>six</td> </tr> </table> <p> <input type="button" onclick="captionfunc('newtable')" value="display table caption"> </p> <p> <input type="button" value="delete row" onclick="document.getelementbyid('newtable').deleterow(0)"> </p> </body></html>
以上就是如何使用javascript dom删除表格中的行?的详细内容。