亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JS動態(tài)添加Table的TR,TD實(shí)現(xiàn)方法

 更新時(shí)間:2015年01月28日 15:51:16   投稿:shichen2014  
這篇文章主要介紹了JS動態(tài)添加Table的TR,TD實(shí)現(xiàn)方法,涉及js針對Table中TR、TD節(jié)點(diǎn)的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JS動態(tài)添加Table的TR,TD實(shí)現(xiàn)方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
<html> 
<head>
<title></title>
<SCRIPT language="JavaScript">
var tempRow=0;
var maxRows=0;
function insertRows(){
tempRow=table1.rows.length-1;
maxRows=tempRow;
tempRow=tempRow+1;
var Rows=table1.rows;//類似數(shù)組的Rows
var newRow=table1.insertRow(table1.rows.length);//插入新的一行
var Cells=newRow.cells;//類似數(shù)組的Cells
for (i=0;i<2;i++)//每行的7列數(shù)據(jù)
{
var newCell=Rows(newRow.rowIndex).insertCell(Cells.length);
newCell.align="center";
switch (i)
{
case 0: newCell.innerHTML="<td valign='top'>corpName</TD>"; break;
case 1 : newCell.innerHTML="<td valign='top'><a href='javascript:delTableRow(\""+tempRow+"\")'>刪除</a></TD>"; break;
}
}
maxRows+=1;
}
function delTableRow(rowNum){
if (table1.rows.length >rowNum){
table1.deleteRow(rowNum);
}
}
</SCRIPT>
</head>
<body>
<form action="">
<table border="0" cellspacing="0" cellpadding="0" width="98%" align="center">
<tr valign="top">
<th>
<input value="添加" type="button" onclick="insertRows()">
</th>
</tr>
</table>
<br />
<table border="1" width="98%" align="center" id="table1">
<tr>
<th >企業(yè)名稱</th>
<th>操作<th>
</tr>
</table>
</form>
</body>
</html>

希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論