<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function createTd(str){
var td=document.createElement('td');
td.innerHTML=str;
return td;
}
function createTr(){
return document.createElement('tr');
}
function createTrs(rows,cols,parent){
var fragment=document.createDocumentFragment();
for(var i=0;i<rows;i++){
tr=createTr();
for(var j=0;j<cols;j++){
tr.appendChild(createTd(i+'行'+j+'列'));
}
fragment.appendChild(tr);
}
parent.appendChild(fragment);
}
window.onload=function(){
var tbody=document.getElementById('a');
createTrs(3,4,tbody);
}
</script>
</head><body>
<table>
<tbody id="a"></tbody>
</table>
</body>
</html>