87,972
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta charset="UTF-8">
<title>用自定义函数定义表格</title>
<script type = "text/javascript">
function table(row,col)
{
var show = "";
show = "<table align ='center' border = '1' width = '600'>";
var bgcolor;
for (i=1;i<=row;i++)
{
if (i%2 != 0){ bgcolor = "#FFFFFF"; }
else { bgcolor = " #DDDDFF";}
show += "<tr bgcolor =' "+bgcolor+"'>";
for (j=1;j<=col;j++)
{
show += "<td height='30'> 第" + i + "行 第" + j + "列 </td>";
}
show += "</tr>";
}
show += "</table>";
return show;
}
</script>
</head>
<body>
<script type ="text/javascript">
var result = table(6,5);
document.write (result);
</script>
</body>
</html>