87,901
社区成员
发帖
与我相关
我的任务
分享
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Table Demo</title>
</head>
<body>
行:<input type="text" id="h"/>
列:<input type="text" id="l"/></br>
<input type="button" value="click" onclick="add();" /></br>
<div id="divid">
</div>
</body>
<script type="text/javascrpt">
function add(){
var row=document.getElementById("h").value;
var col=document.getElementById("l").value;
var tab="<table border='1' bordercolor='blue'>";
// 循环行
for(var i=0;i<row;i++){
tab+="<tr>";
for(var j=0;j<col;j++){
tab+="<td>hhhh</td>";
}
tab+="</tr>"
}
tab+="</table>";
var divv=document.getElementById("divid");
divv.innerHTML=tab;
}
</script>
</html>