這篇文章介紹了js添加table的行和列 具體實現方法
代碼如下
<!DOCTYPE html PUBLIC
<html xmlns=
<head>
<title></title>
<script language=
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 = [
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=
<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=
</div>
<br />
<hr />
<br />
<div>
<input type=
<table id=
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type=
<table id=
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type=
<table id=
<tr>
<th>
Name
</th>
<th>
Age
</th>
</tr>
</table>
</div>
<br />
<hr />
<br />
<div>
<input type=
<div id=
</div>
<br />
<hr />
<br />
<div>
<input type=
</div>
</body>
</html>
【責編:at
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19306.html