我有一个包含多行输入字段的表。我想复制第二行或第三行我的代码在这里:但是 cloneNode 在 IE7 中不起作用,请帮助。此代码在其他主要浏览器中有效,但在 IE7 中无效 function deleteRow(row) { var x=document.getElementById('rowcontainer');
var len = parseInt(x.rows.length);
if(len>4)
{
var i=row.parentNode.parentNode.rowIndex;
document.getElementById('rowcontainer').deleteRow(i);
}
else
{
alert('Minimum 3 rows are required');
}
}
function insRow()
{
var x=document.getElementById('rowcontainer');
var len = parseInt(x.rows.length);
if(len % 2 == 0)
{
var new_row = x.rows[1].cloneNode(true);
}
else
{
var new_row = x.rows[2].cloneNode(true);
}
x.appendChild( new_row );
$('#rowcontainer tr:last :input').val('');
}
</script>
</head>
<body>
<table width="100%" border="0" style="border:solid 1px #d1d1d1; line-height:21px;" cellpadding="0" cellspacing="0" id="rowcontainer">
<tr style="background:#e0e0e0; line-height:33px;">
<td class="tblborder" style="width:23px; text-align:center; padding:0px; cursor:pointer;"><div id="addrow" onclick="insRow()">+</div></td>
<td class="tblborder">Item</td>
<td class="tblborder">Description</td>
<td class="tblborder">Quantity</td>
<td class="tblborder">Unit Price</td>
<td class="tblborder">Discount</td>
<td class="tblborder_b" style="text-align:left;">Sub-Total</td>
</tr>
<tr style="background:#f5f5f5;">
<td class="tblborder" style="background:#e0e0e0; padding:0px; text-align:center; cursor:pointer;"><div id="delrow" onclick="deleteRow(this)">-</div></td>
<td class="tblborder"><input type="text" class="rowinpt desc_item" onclick="openitemdialob();" /></td>
<td class="tblborder"><input type="text" class="rowinpt desc_item" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder_b"><input type="text" class="rowinpt subtotal" id="subtotalinput" /></td>
</tr>
<tr>
<td class="tblborder" style="background:#e0e0e0; padding:0px; text-align:center; cursor:pointer;"><div id="delrow" onclick="deleteRow(this)">-</div></td>
<td class="tblborder"><input type="text" class="rowinpt desc_item" onclick="openitemdialob();" /></td>
<td class="tblborder"><input type="text" class="rowinpt desc_item" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder"><input type="text" class="rowinpt subtotal" /></td>
<td class="tblborder_b"><input type="text" class="rowinpt subtotal" id="subtotalinput" /></td>
</tr>
</table>
</body>
</html>