您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何使用JavaScript DOM删除表格中的行?

2024/11/26 3:03:18发布17次查看
要在 javascript 中删除表中的行,请使用 dom deleterow() 方法。
示例您可以尝试运行以下代码以了解如何删除表中的行。该代码一次删除一行 -
现场演示
<!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删除表格中的行?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product