<script type="text/javascript">
$(document).ready(function() {
var num=getRandom(5,20); //5-20之间的随机数,包括5和20
alert(num);
});
//获取随机数
function getRandom(x,y){
//x 下限
//y 上限
return parseInt(Math.random() * (y - x + 1) + x) ;
$(document).ready(function() {
var num=getRandom(5,20); //5-20之间的随机数,包括5和20
alert(num);
});
//获取随机数
function getRandom(x,y){
//x 下限
//y 上限
return parseInt(Math.random() * (y - x + 1) + x) ;
}
parseInt(10*Math.random()) //输出0~10之间的随机整数
Math.floor(Math.random()*10+1) //输出1~10之间的随机整数
</script>