var tableObject = document.getElementById("test");
var newRowIndex = tableObject.rows.length;
var newRowObject_f= tableObject.insertRow(newRowIndex);//增加一行
newRowObject_f.id ="bb";//设置增加这行的id
var newCellObject_f1 = newRowObject_f.insertCell(0);//给增加这行加入单元格
newCellObject_f1.id="cc";
var newCellObject_f2 = newRowObject_f.insertCell(0);//给增加这行加入单元格
newCellObject_f2.style="dd";
想通过id设置单元格的style,但是测试不成功 测试Row时可以实现 测试cell时不能实现
var newRowIndex = tableObject.rows.length;
var newRowObject_f= tableObject.insertRow(newRowIndex);//增加一行
newRowObject_f.id ="bb";//设置增加这行的id
var newCellObject_f1 = newRowObject_f.insertCell(0);//给增加这行加入单元格
newCellObject_f1.id="cc";
var newCellObject_f2 = newRowObject_f.insertCell(0);//给增加这行加入单元格
newCellObject_f2.style="dd";
想通过id设置单元格的style,但是测试不成功 测试Row时可以实现 测试cell时不能实现
<body onload="load()">
<script type="text/javascript">
<!--
function load()
{
document.getElementById("td1").style.fontSize = 50;
}
//-->
</script>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td id="td1">3</td>
<td>4</td>
</tr>
</table>
</body>
var newRowIndex = tableObject.rows.length;
var newRowObject_f= tableObject.insertRow(newRowIndex);//增加一行
newRowObject_f.innerHTML = '<input type="text" id = "dd" style = "background-color:red">';
是说这个意思吧
newRowObject_f.id ="bb";//设置增加这行的id
这段代码可以给一个<tr>添加一个id
问题是
newCellObject_f1.id="cc";
这段代码正确吗 能不能这样给这个单元格添加Id