js table表格某一行新插入数据 和删除某一行数据

tech2025-04-09  7

var x= document.getElementById("imp").insertRow(1); var y=x.insertCell(0); var z=x.insertCell(1); var q=x.insertCell(2); var w=x.insertCell(3); var e=x.insertCell(4); /* y.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr align="center" style="font-size: 18px;color: #0B98C3">站点名称 &nbsp;&nbsp;&nbsp;</nobr></marquee>';*/ y.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr ">'+obj.siteName+' </nobr></marquee>'; z.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr ">'+obj.dataTime.toString().substring(11,19)+' </nobr></marquee>'; if (obj.ois>obj.alarmLimit) { q.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr style="color: red" >'+ obj.ois +'(mg/m³)</nobr></marquee>'; }else { q.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr style="color: green">'+ obj.ois +'(mg/m³)</nobr></marquee>'; } w.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr "> '+obj.pmx+'(mg/m³) </nobr></marquee>'; e.innerHTML=' <marquee direction="down" behavior="slide" scrollamount="1" scrolldelay="10" height="85%" > <nobr "> '+obj.voc+'(mg/m³) </nobr></marquee>'; $("#imp tbody tr").find('td:eq(0)').css('width','24%'); $("#imp tbody tr").find('td:eq(1)').css('width','15%'); $("#imp tbody tr").find('td:eq(2)').css('width','20%'); $("#imp tbody tr").find('td:eq(3)').css('width','20%'); $("#imp tbody tr").find('td:eq(4)').css('width','20%'); var tab = document.getElementById("imp") ; //表格行数 var rows = tab.rows.length; if (rows > 50){ tab.deleteRow(rows-1);//删除某一行 }

 

最新回复(0)