复制代码代码如下:
<html>
<head>
<script>
وظيفة CreateTable (صفوف ، خطوط) {
this.rows = الصفوف ؛
this.lines = الخطوط ؛
var body = document.getElementById ('body') ؛
var table = document.createElement ('table') ؛ // 创建 table 标签元素
table.setattribute ('الحدود' ، '1') ؛
// 给 الجدول 标签添加其他属性
لـ (var i = 0 ؛ i <this.rows ؛ i ++) {
var lrow = document.createElement ('tr') ؛
لـ (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"> </viv>
</body>
<script type = "text/javaScript">
CreateTable (10،10) ؛
</script>
</html>
: :
复制代码代码如下:
<script>
وظيفة CreateTable (صفوف ، خطوط) {
this.rows = الصفوف ؛
this.lines = الخطوط ؛
var body = document.getElementById ('body') ؛
var table = document.createElement ('table') ؛
table.setattribute ('الحدود' ، 1) ؛
لـ (var i = 0 ؛ i <this.rows ؛ i ++) {
var row = table.insertrow (i) ؛
لـ (var j = 0 ؛ j <this.lines ؛ j ++) {
var cells = row.insertcell (j) ؛
cells.innerhtml = i+'،'+j
}
}
body.appendchild (الجدول) ؛
}
</script>