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

js生成随机数

时间:2017-06-05 12:36:17      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:tle   dom   ack   script   pos   write   4.0   tracking   content   

<!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()*99+1));//生成一个1~100(包含1和100)的随机整数
</script>
</body>
</html>

js生成随机数

标签:tle   dom   ack   script   pos   write   4.0   tracking   content   

原文地址:http://www.cnblogs.com/wzjhoutai/p/6944202.html

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