<!DOCTYPE html PUBLIC "
<html xmlns="
<head>
<title></title>
<script language="javascript" type="text/javascript">
function addRow() {
var newTR = document
var newNameTD = newTR
newNameTD
var newNameTD = newTR
newNameTD
var newNameTD = newTR
newNameTD
var newNameTD = newTR
newNameTD
}
function insertRow() {
var oTable = document
var oTr = oTable
var oTd = oTr
oTd
}
function insertRow
//獲取table對象
var table = document
//找到要添加button的td
var oTd = table
//添加button到td中
oTd
}
function insertRow
var oTable = document
var oTr = oTable
var oTd = oTr
oTd
}
function insertRow
//獲取table對象
var table = document
//找到要添加button的td
var oTd
oTd
}
function tableDiv() {
var maxRow =
var maxCol =
var strTbody = ["<table border=
for (var i =
strTbody
for (var j =
strTbody
}
strTbody
}
strTbody
var obj = document
obj
}
function init() {
var _table
var docBody = document
var _doc = document;
maxRow =
maxCol =
_table = _doc
_table
_table
_tbody = _doc
_table
docBody
for (var i =
tr = _doc
_tbody
for (var j =
td = _doc
text = _doc
td
tr
}
}
}
</script>
</head>
<body>
<div>
<table id="testTable" border=
<tr>
<th>
FirstName
</th>
<th>
LastName
</th>
<th>
BirthDay
</th>
<th>
age
</th>
</tr>
<tr>
<td>
Jim
</td>
<td>
Green
</td>
<td>
L
</td>
<td>
</td>
</tr>
<tr>
<td>
Andrew
</td>
<td>
Hou
</td>
<td>
Xi
</td>
<td>
</td>
</tr>
</table>
<input type="button" id="aaa" value="+add new Row" onclick="addRow();" />
</div>
<br />
<hr />
<br />
<div>
<input type="button" value="按鈕添加行" onclick="insertRow();" />
<table id="table_info" border="
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type="button" value="按鈕中添加行" onclick="insertRow
<table id="table_info
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type="button" value="連續添加列" onclick="insertRow
<table id="table_info
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type="button" value="添加一個table" onclick="tableDiv();" />
<div id="tableDiv" />
</div>
<br />
<hr />
<br />
<div>
<input type="button" value="連續添加table" onclick="init();" />
</div>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20169.html