救救我,作業緊急
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>游戲卡</title>
<style type="text/css" >
#p{background-color:#99CC99; width:400px; height:400px;border:5px;}</style>
<script type="text/javascript">
function a (){
var b=document.getElementById(p);
var c=Math.random()*100;
document.write(Math.round(c));}
widow.onload=a();
</script>
</head>
<body><table id="p"><tr><td></td><td></td><td></td><td></td><td></td></tr>?
? ? ? ? ? ? ? ? ? ? <tr><td></td><td></td><td></td><td></td><td></td></tr>?
<tr><td></td><td></td><td></td><td></td><td></td></tr>?
<tr><td></td><td></td><td></td><td></td><td></td></tr>?
<tr><td></td><td></td><td></td><td></td><td></td></tr>?
</table>
</body>
</html>
要在表格隨機生成數字,怎么實現
2016-12-29
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>游戲卡</title> <script?type="text/javascript"> function?a?(){ var?sty?=?"<style?type="?+?"text/css"+"?>#p{background-color:#99CC99;?width:400px;?height:400px;border:5px;}</style>"; document.write(sty); document.write("<table?border?=?1??id?="?+?"p"?+">"); for?(var?i=0;i<5;i++){ ????document.write("<tr>"); ????for?(var?j?=0;j<5;j++){ ????????document.write("<td>"); ????????document.write(Math.round(Math.random()*100)); ????????document.write("</td>"); ????} ????document.write("</tr>"); } document.write("</table>"); } </script> </head> <body?onload="a()"> </body> </html>2016-12-29
Math.random 吧,有幾個表格循環random幾次就可以了
2016-12-29
用Math.random()方法可返回介于 0 ~ 1(大于或等于 0 但小于 1 )之間的一個隨機數。用Math.round(x)可以四舍五入。