我在H5中编译应用自定义函数定义表格时
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 +="</table>";
return show;
}
</script>
</head>
<body>
< script type ="text/javascript">
var result = tableb (6,5);
document.write (result);
</script>
</body>
</html>

解决方案 »

  1.   


    <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>