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()*99+1));//生成一个1~100(包含1和100)的随机整数
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/wzjhoutai/p/6944202.html