第1个回答 2013-09-30
<html>
<script>
function initTable(){
var table=document.getElementById("div-table");
var data="<table border='1' cellpadding='0' cellspacing='0'>";
data+="<colgroup><col style='width:110px;'/><col style='width:110px;'/><col style='width:110px;'/></colgroup>";
data+="<tr><td>姓名</td><td>英语</td><td>高数</td></tr>";
data+="<tr><td>李丽</td><td>85</td><td>78</td></tr>";
data+="<tr><td>王明</td><td>81</td><td>82</td></tr>";
data+="</table>";
table.innerHTML=data;
}
window.onload=initTable;
</script>
<body>
<div id="div-table"></div>
</body>
</html>
第2个回答 2013-10-01
就如一楼,不过要是你只是做一个表格的话,用<table></table>就可以了
第3个回答 2013-09-30
&lt;script&gt; var tmp=&quot;&lt;table border=1 cellspacing=0 bordercolor=0 &gt;&quot;; for(i=0;i&lt;9;i++){ if(i%3==0) tmp+=&quot;&lt;tr&gt;&quot;; tmp+=&quot;&lt;td&gt;&quot;+(i+1)+&quot;&lt;&#47;td&gt;&quot;;if((i+1)%3==0) tmp+=&quot;&lt;&#47;tr&gt;&quot;; } tmp+=&quot;&lt;&#47;table&gt;&quot;; document.write(tmp); &lt;&#47;script&gt;没试下就抢了,这次的试过了018