js怎样设置td中input的css样式,js动态平添的行中td的样式不起作用

当前位置:我的异常网» 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");

文章评论

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值