gpt4 book ai didi

javascript - 使用 javascript 在两行之间创建一个表行?

转载 作者:行者123 更新时间:2023-11-30 13:32:56 26 4
gpt4 key购买 nike

如何在 2 之间创建表格行?我正在使用下面的代码创建一行。

 if (!document.getElementsByTagName) return;
tabBody=document.getElementsByTagName("TBODY").item(0);

row=document.createElement("TR");

cell1 = document.createElement("TD");

textnode1=document.createTextNode('');

cell1.appendChild(textnode1);


row.appendChild(cell1);

tabBody.appendChild(row);


}

实际上我想将它创建为中间一行。目前我的表有 2 行。

最佳答案

一个表暴露了它自己的方法,可以用来修改它:

- insertRow 
- deleteRow

表格行公开了一个可用于插入新单元格的方法:插入单元格
Here是一些基本的例子。

关于javascript - 使用 javascript 在两行之间创建一个表行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6080563/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com