最初の方法:
コードコピーは次のとおりです。
<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>
2番目の方法:
コードコピーは次のとおりです。
<スクリプト>
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>
上記の2つの方法を理解しましたか?より良い方法がある場合は、それを説明して一緒に進歩を遂げるためにメッセージを残してください。