通过javascript删除table的行或列的步骤
通过javascript删除table的行或列的步骤
以下这些没有经过整理,但还是可以看懂得
<html>
<body>
<div id="rr">
<table id="t" width='100%' border='1' align='center' cellpadding='2' cellspacing='1' class='border3' onClick="cc(this);">
<tr align='center' class='tdbg2' height='25'>
<td width='32' id="t1"><b>购买</b></td>
<td id="t2"><b>商 品 名 称</b></td>
<td width='44' id="t3"><b>单 位</b></td>
<td width='54' id="t4"><b>数 量</b></td>
<td width='64' id="t5"><b>商品类别</b></td>
<td width='64'><b>销售类型</b></td>
<td width='64'><b>原价</b></td>
<td width='44'><b>折扣</b></td>
<td width='64'><b>实价</b></td>
<td width='84'><b>金 额</b></td>
</tr>
<tr valign='middle' class='tdbg3' height='20'>
<td width='32' align='center'><input type='CheckBox' name='ProductID' value='1' Checked></td>
<td align='left'>Zuluhed - Horde</td>
<td width='44' align='center'>G</td>
<td width='54' align='center'><input name='Amount_1' type='Text' value='1' size='5' maxlength='10' style='text-align: center;'></td>
<td width='64' align='center'>正常销售</td>
<td width='64' align='center'>零售</td>
<td width='64' align='right'>0.15</td>
<td width='44' align=center>─</td>
<td width='64' align='right'>0.15</td>
<td width='84' align='right'>0.15</td>
</tr>
<tr class='tdbg3'>
<td id="dd" colspan='9' align='right'><b>合计:</b></td>
<td width='80' align=right><b> ¥0.15</b></td>
</tr>
</table>
</div>
<script language="javascript">
objTable = document.getElementById("t");
//document.getElementById("dd").colSpan=6;
//objTable.rows[2].children[0].setAttribute("colSpan",6);
if(objTable.rows.length){
for(var i=0;i<objTable.rows.length;i++)
{
alert("櫖");
objTable.rows[i].removeChild(objTable.rows[i].children[2])
objTable.rows[2].children[0].setAttribute("colSpan",8);
}
}
//alert("fdsaf");
// objTable = document.getElementById("t");
//alert(objTable.Row);
// newRow = objTable.deleteRow(2);
//rr.innerHTML.replace("<td",
//alert("fdsafds");
//alert(rr.innerHTML);
</script>
</body>
</html>