码迷,mamicode.com
首页 > Web开发 > 详细

js生成随机数

时间:2014-05-18 09:09:49      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:js   随机数   

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JS随机数测试</title>
</head>
<body>
<script>
document.write(Math.random());//生成一个0~1之间的很多位数的随机小数
</script>
<br>
<script>
document.write(Math.round(Math.random()*9+1));//生成一个1~10(包括1和10)的随机整数
</script>
<br>
<script>
document.write(Math.round(Math.random()*90+10));//生成一个1~100(包括1和100)的随机整数
</script>
</body>
</html>

js生成随机数,布布扣,bubuko.com

js生成随机数

标签:js   随机数   

原文地址:http://blog.csdn.net/wuji_1/article/details/25990857

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!