<script language="javascript"> /** * 隨機生成4位的隨機數(shù) * http://www.jbxue.com */ document.write(parseInt(10*Math.random())); //輸出0~10之間的隨機整數(shù) document.write(Math.floor(Math.random()*10+1)); //輸出1~10之間的隨機整數(shù) function RndNum(n){ var rnd=""; for(var i=0;i<n;i++) rnd+=Math.floor(Math.random()*10); return rnd; } document.write(RndNum(4)); //輸出指定位數(shù)的隨機數(shù)的隨機整數(shù) </script>
!評論內(nèi)容需包含中文