日期:2014-05-16 浏览次数:20357 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>蓝光-BlueShine</title>
<script language="JavaScript">
var Count=false,NO=-1;
function addRow(){
Count=!Count;
//添加一行
var newTr = new Array(20);
for(var i=0;i<20;i++)
{
newTr[i] = testTbl.insertRow(testTbl.rows.length);
//添加两列
//alert("add");
var newTd0 = newTr[i].insertCell();
var newTd1 = newTr[i].insertCell();
var newTd2 = newTr[i].insertCell();
var newTd3 = newTr[i].insertCell();
//设置列内容和属性
if(Count)
{
newTr[i].style.background="#FFE1FE";
}
else
{
newTr[i].style.background="#FFEFDF";
}
newTd0.innerHTML = "2013-09-09 10:10";
newTd1.innerHTML = "电表通讯故障";
NO++;
newTd2.innerText="第"+ NO +"行";
}
}
</script>
</head>
<body>
<table align="center" width="399" border=0 cellspacing="1" id="testTbl" style="font-size:14px;">
<tr bgcolor="#FFEFD5">
<td width=6%>
</td>
<td >序号</td>
<td > 设备</td>
<td > 时间</td>
</tr>
</table>
<label>
<input type="button" value="插入行" onclick="addRow()"/>
</label>
</body>
</html>