html 动态添加TABLE的行。

<script type="text/javascript"> 
var pos =4;//默认位置为4,根据自己需要,也可以通过鼠标事件获取当前行数。

function insRow() //增加TR
{ 
var x=document.getElementById('fb').insertRow(pos) ;
x.innerHTML= "<tr>\
                    <td width=\"9%\" height=\"50\" align=\"center\">版本:</td>\
                    <td width=\"23%\" align=\"left\"><input\
                        id=\"input_product_class\" class=\"input-block-level\"name=\"version\" type=\"text\"></td>\
                    <td width=\"6%\" align=\"center\">价格:</td>\
                    <td width=\"26%\" align=\"left\"><input id=\"input_product_price\" class=\"input-block-level\" name=\"pricePerUnit\" type=\"text\"></td>\
                    <td width=\"10%\" align=\"center\">促销价格:</td>\
                    <td width=\"26%\" align=\"left\"><input id=\"input_product_inventory\" class=\"input-block-level\" name=\"inventory\" type=\"text\"></td>\
                    <tdn οnclick=\"delRow()\" class=\"close\">×<td>\
                    </tr>";


pos=pos+1;
}
function delRow()//删除TR,不过只能从后向前依次删除,否则就或删错。因为我的POS不是鼠标获取的,所以无法随意删除。
{ 
    document.getElementById('fb').deleteRow(pos-1);
    pos=pos-1;
}


</script>

 

转载于:https://www.cnblogs.com/shenghaishiweini/p/3591315.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值