insertRow Method Internet Development Index --------------------------------------------------------------------------------Creates a new row (tr) in the table, and adds the row to the rows collection. SyntaxoTR = object.insertRow( [iIndex])
ParametersiIndex Optional. Integer that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. Return ValueReturns the tr element object if successful, or null otherwise. ResIf you insert a row in a tFoot, tBody, or tHead, you also need to add the row to the rows collection for the table. If you insert a row in the table, you also need to add the row to the rows collection for the tBody. If you specify an index, the index should be relative to the rows collection for the element that first contains the tr. For example, if you call this method for a tBody, you must specify an index value relative to the rows collection that is on the tBody, not the table. The preferred technique for inserting a row is to add the row at the end of the rows collection. It is faster to add a row at the end of a table than somewhere in the middle. To add a row at the end of the collection, specify the -1 value, or the length of the rows collection minus 1.ExampleThis example uses the insertRow method to add a row to the table. myNewRow = document.all.myTable.insertRow()
ParametersiIndex Optional. Integer that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. Return ValueReturns the tr element object if successful, or null otherwise. ResIf you insert a row in a tFoot, tBody, or tHead, you also need to add the row to the rows collection for the table. If you insert a row in the table, you also need to add the row to the rows collection for the tBody. If you specify an index, the index should be relative to the rows collection for the element that first contains the tr. For example, if you call this method for a tBody, you must specify an index value relative to the rows collection that is on the tBody, not the table. The preferred technique for inserting a row is to add the row at the end of the rows collection. It is faster to add a row at the end of a table than somewhere in the middle. To add a row at the end of the collection, specify the -1 value, or the length of the rows collection minus 1.ExampleThis example uses the insertRow method to add a row to the table. myNewRow = document.all.myTable.insertRow()
解决方案 »
- 这种写法是用jquery吗
- window.location.href后不能跟变量?
- 急!急!急!关于html中的onclick 与 jQuery中的onclick
- Ext3.0培训
- 奇怪的Javascript四舍五入,很BT啊
- Array.prototype.join.call的疑问
- html 打印多页内容 如何根据表格大小自动分页 同时添加页首页尾
- 我想做一个跟数据库相连的弹出式菜单,高手赐教~~急
- 请教如何将表格中的几行隐藏起来,适当的时候再显示出来
- 为什么按F5刷新都无效,非要点击菜单,选择Internet选项,手工清除缓存文件才可以显示最新的内容?
- 高分,如何用javascript寫出類vb的ide的界面
- 还是老的输入框赋值的问题到现在还没解决
<HEAD>
<style>
table.description {
border: 2px solid black;
border-collapse: collapse;
font-size: x-small;
border-color:#2E8B57;}
.aqua {
background-color: #DDDDDD;
color: black;
white-space: nowrap;
border: 1px solid black;
border-color:#666666;
}
.white {
background-color: white;
color: black;
white-space: nowrap;
border: 1px solid black;
border-color:#666666;
}
.input_char_l {
ime-mode:disabled;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function addLine(){
var obj=document.getElementById("table1")
var index=obj.childNodes[0].childNodes.length;
var objTr=obj.childNodes[0].childNodes[1].cloneNode(true);
obj.childNodes[0].appendChild(objTr);
for(var i=0;i<objTr.childNodes.length;i++)
{
objTr.childNodes[i].innerHTML=objTr.childNodes[i].innerHTML.replace(/1/g,index);
}
}
//-->
</SCRIPT>
</HEAD>
<BODY> <table class="description" cellpadding="3" border="1" id="table1">
<tr>
<th class="aqua">
a
</th>
<th class="aqua">
b
</th>
<th class="aqua">
c
</th>
<th class="aqua">
d
</th>
<th class="aqua">
e
</th>
<th class="aqua">
f
</th>
</tr>
<tr>
<td class="white"align = "center">
1
</td>
<td class="white"align = "center">
1
</td>
<td class="white"align = "center">
1
</td>
<td class="white"align = "center">
1
</td>
<td class="white"align = "center">
1
</td>
<th class="white" align="center">
<input type="text" name="TextA" value="1" class="input_char_l">
</th>
</tr>
<tr>
<td class="white"align = "center">
2
</td>
<td class="white"align = "center">
2
</td>
<td class="white"align = "center">
2
</td>
<td class="white"align = "center">
2
</td>
<td class="white"align = "center">
2
</td>
<th class="white" align="center">
<input type="text" name="TextA" value="2" class="input_char_l">
</th>
</tr>
</table>
<input type='button' value="Add Line" onclick="addLine()">
</BODY>
</HTML>