日期:2014-05-16  浏览次数:20394 次

js操作表格
<html>

<head>

<script>
function addSuffixRow(){
	//alert(document.all.suffixTable.innerHTML)
	if(document.all.suffixTable.rows.length > 19){
		alert("您最多可以批量查询60个域名。");
	}else{
	
		//添加一行
		var newTr = document.all.suffixTable.insertRow();
		//添加两列
		var newTd0 = newTr.insertCell();
		var newTd1 = newTr.insertCell();
		var newTd2 = newTr.insertCell();
                
		newTd0.width="33%";
		newTd1.width="33%";
		newTd2.width="33%";
		

		//设置列内容和属性
		newTd0.innerHTML = '<input name="suffix" type="text" class="input" maxlength="70" style="width:195;">';
		newTd1.innerHTML = '<input name="suffix" type="text" class="input" maxlength="70" style="width:195;">';
		newTd2.innerHTML = '<input name="suffix" type="text" class="input" maxlength="70" style="width:195;">';

	}
}


function deleteSuffixRow(){
	if(document.all.suffixTable.rows.length == 1){
		alert("不能删除最后一行!");
	}else{
		var lastIndex = document.all.suffixTable.rows.length - 1;
		document.all.suffixTable.deleteRow(lastIndex);
	}
}

function traceTable() {
	var k = document.all.suffixTable.rows.length;
	var l = document.all.suffixTable.rows[0].cells.length;
        alert(document.all.suffixTable.rows[0].cells[1].innerHTML);
 	alert(document.all.suffixTable.rows[0].cells[1].childNodes[0].innerText="输入的字");


}

</script>
</head>
<body>
	<table width="99%" border="0" cellpadding="0" cellspacing="1" id="suffixTable"
								class="DoubleColorTable">
								<tr>
									<td style="width: 33%"  align="left">
										<input name="suffix" type="text" class="input" maxlength="77"
										 style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
								</tr>
								<tr>
									<td style="width: 33%"  align="left">
										<input name="suffix" type="text" class="input" maxlength="77"
										 style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
								</tr>
								<tr>
									<td style="width: 33%"  align="left">
										<input name="suffix" type="text" class="input" maxlength="77"
										 style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
									<td style="width: 33%" >
										<input name="suffix" type="text" class="input" maxlength="77"
										  style="width:195;"/>
									</td>
								</tr>
							</table>
								<!-- tr id="list" style="display:none;">
									<td align="left">
										<input name="suffix" type="text" class="input"
											style="width:100%;" />
									</td>
									<td>
										<input name="suffix" type="text" class="input"
											style="width:100%;" />
									</td>
									<td>
										<input name="suffix" type="text" class="input"
											style="width:100%;" />
									</td>
								</tr -->
						</div>
						<div style="background:#fff; padding:5px; height:20px;">
							<p class="textLeft">
								<a href="#" onclick="addSuffixRow();return false;">点击这里添加一行</a>
							</p>
							<p