首页 > Web开发 > 详细

html 动态添加TABLE的行。

时间:2014-03-11 07:03:21      阅读:511      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<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 onclick=\"delRow()\" class=\"close\">×<td>                    </tr>";


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


</script>
bubuko.com,布布扣

html 动态添加TABLE的行。,布布扣,bubuko.com

html 动态添加TABLE的行。

原文:http://www.cnblogs.com/shenghaishiweini/p/3591315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!