当前位置:我的异常网» JavaScript » js动态平添的行中td的样式不起作用
js动态平添的行中td的样式不起作用
www.myexceptions.net 网友分享于:2013-10-11 浏览:79次
js动态添加的行中td的样式不起作用
各位大虾会的就帮帮忙,在线等
在表格中原先有一行,动态添加的行中td的样式不起作用,是什么问题?
代码如下
在3的基础上删除delete改为删除选中行.td0{background-color:White ;width:500px;}
.td1{background-color:White ;width:80px;}
.td2{background-color:White ;width:100px;}
.td3{background-color:White ;width:200px;}
.td4{background-color:White ;width:100px;}
var linenum = 1;
var strvalue;
var strtext;
function countWeight()
{
var WeightT = 0;
for (var i=1 ;i<= linenum ;i++)
{
if (document .all["tb_line"+i].value == "" || document .all["tb_line"+i].value ==null)
{
}
else
{
var weight = parseInt(document .all["tb_line"+i].value);
if(weight<=100 && weight >0)
{
WeightT += parseInt(document .all["tb_line"+i].value);
}
else
{
alert ("权重必须是0到100之间的数字!");
}
}
}
document .all["lb_weight"].innerHTML = WeightT ;
};
function delTR(obj)
{
var table = obj .parentNode.parentNode.parentNode;
table .removeChild(obj .parentNode.parentNode);
};
function Add_tr()
{
if (linenum ==1)
{
getoption ();
}
linenum =linenum +1;
var tableobj = document .getElementById ("table1");
var trobj = document .createElement ("tr");
trobj .setAttribute ("id","tr"+linenum);
// 添加td0
var tdobj0 = document .createElement ("td");
tdobj0 .setAttribute ("class","td0");
var textareaobj0 = document .createElement ("textarea");
textareaobj0.setAttribute ("id","ta_line"+linenum );
textareaobj0.setAttribute ("name","ta_line"+linenum );
textareaobj0 .setAttribute ("cols","35");
textareaobj0 .setAttribute ("rows","2");
tdobj0 .appendChild(textareaobj0 );
trobj .appendChild (tdobj0 );
// 添加td1
var tdobj1 = document .createElement ("td");
tdobj1 .setAttribute ("class","td1");
var textobj1 = document .createElement ("input");
textobj1.setAttribute ("id","tb_line"+linenum );
textobj1.setAttribute ("name","tb_line"+linenum );
textobj1.setAttribute ("runat","server");
文章评论