js函数在页面上打印一个N行M列的表格,表格内容填充为1~100之间的随机数
Posted Cupid
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js函数在页面上打印一个N行M列的表格,表格内容填充为1~100之间的随机数相关的知识,希望对你有一定的参考价值。
打印一个10x10的表格
function tab(n,m){
document.write("<table border=1 cellpadding=0 cellspacing=0 >");
for(var i=0; i<n; i++){
document.write("<tr>");
for(var j=0; j<m; j++){
document.write("<td style=‘width: 40px; height: 40px;‘>");
document.write( Math.round( Math.random()*100 ) );
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table>");
}
tab(10,10);
以上是关于js函数在页面上打印一个N行M列的表格,表格内容填充为1~100之间的随机数的主要内容,如果未能解决你的问题,请参考以下文章