<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="div1">
<input id="button1" type ="button" value="点我自动生成表格" οnclick="dianwo()" />
</div>
<script>
function dianwo(){
var table=document.createElement("table");
var div1=document.getElementById("div1");
var tr=table.insertRow();
var td0=tr.insertCell(0);
var td1=tr.insertCell(1);
var td2=tr.insertCell(2);
table.setAttribute("border","1")
td0.innerText="张三";
td1.innerText="李四";
td2.innerText="王五";
div1.appendChild(table);
}
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="div1">
<input id="button1" type ="button" value="点我自动生成表格" οnclick="dianwo()" />
</div>
<script>
function dianwo(){
var table=document.createElement("table");
var div1=document.getElementById("div1");
var tr=table.insertRow();
var td0=tr.insertCell(0);
var td1=tr.insertCell(1);
var td2=tr.insertCell(2);
table.setAttribute("border","1")
td0.innerText="张三";
td1.innerText="李四";
td2.innerText="王五";
div1.appendChild(table);
}
</script>
</body>
</html>