复制代码代码如下:
<html>
<head>
<スクリプト>
function createTable(行、行){
this.rows = rows;
this.lines = lines;
var body = document.getElementById( 'body');
var table = document.createelement( 'table'); //创建テーブル标签元素
table.setattribute( 'border'、 '1');
//给テーブル标签添加其他属性
for(var i = 0; i <this.rows; i ++){
var lrow = document.createelement( 'tr');
for(var j = 0; j <this.lines; j ++){
var textnode = document.createTextNode(i+'、'+j);
var lline = document.createelement( 'td');
lline.AppendChild(textNode);
lrow.AppendChild(LLine);
}
Table.AppendChild(LROW);
}
body.appendChild(表);
}
</script>
</head>
<body>
<div id = "body"> </div>
</body>
<script type = "text/javascript">
createTable(10,10);
</script>
</html>
第二种方法:
复制代码代码如下:
<スクリプト>
function createTable(行、行){
this.rows = rows;
this.lines = lines;
var body = document.getElementById( 'body');
var table = document.createelement( 'table');
table.setattribute( 'border'、1);
for(var i = 0; i <this.rows; i ++){
var row = table.insertrow(i);
for(var j = 0; j <this.lines; j ++){
var Cells = row.insertcell(j);
cells.innerhtml = i+'、'+j
}
}
body.appendChild(表);
}
</script>