刚学JS的同学来看看,利用JS输入一个5*5的表格,简单无比!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js 输出5*5表格</title>
<script type="text/javascript">
//用弹框内容自己控制表格的长宽和边框
var w = prompt("请输入表格的宽度");
var h = prompt("请输入表格的高度");
var b = prompt("请输入表格的边框");
//随机生成0~255的值。
var num1 =Math.random()*255;
var num2 =Math.random()*255;
var num3 =Math.random()*255;
console.log(w,h,b)
document.write("<table width="+w+" height="+h+" border="+b+" style='background:rgb("+num1+","+num2+","+num3+")'>")
document.write("<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>");
document.write("<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>");
document.write("<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>");
document.write("<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>");
document.write("<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>");
document.write("</table>");
</script>
</head>
<body>
</body>
</html>