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

JS增加TABLE行
<html>
<head>
<script type="text/javascript">
var test = {};
test.doalert = function(str){
alert(str);
}
function aaa(){
var table = document.getElementById("tableId");
var num = table.rows.length-1;
var oRow = table.insertRow();
var hideTable = document.getElementById("realtion");
for(var i = 0;i<hideTable.cells.length;i++){
var oCell = oRow.insertCell(i);
oCell.innerHTML = hideTable.cells(i).innerHTML.replace(new RegExp("@","gm"), "" + num);
      oCell.colSpan = hideTable.cells(i).colSpan;
      oCell.rowSpan = hideTable.cells(i).rowSpan;
      oCell.vAlign = hideTable.cells(i).vAlign;
      oCell.align = hideTable.cells(i).align;
      oCell.bgColor = hideTable.cells(i).bgColor;
      oCell.style.cssText = hideTable.cells(i).style.cssText;
      oCell.className = hideTable.cells(i).className;     
}

}
function bbb(){
alert(varr[0].code);
}
setTimeout("test.doalert('sdsdsdsdsd')",5000);
</script>
</head>
<body >
<div id = "divx" border="1" overflow="auto">
<table border = "1" id="tableId">
<tr id="dd"><td style="margin-top:0px"><span>sss</span></td><td><textarea rows="8" name="sss" class="text"></textarea>
</td></tr>
</table>
<table id="realtion" style="display:none">
<tr id="dd"><td style="margin-top:0px"><span>sss</span></td><td><textarea rows="8" name="sss" class="text"></textarea>
</td></tr>
</table>
<input type="button" value="go" onclick="aaa()"/>
</div>
</body>
</html>