function selectFrom(iFirstValue, iLastValue){
var iChoices = iLastValue - iFirstValue + 1; //计算项数
return Math.floor(Math.random()*iChoices+iFirstValue);
}
var iNum = selectFrom(2,99); //随机产生2~99之间的数字
alert(iNum);
js 自定范围产生随机数字
最新推荐文章于 2023-07-17 13:44:32 发布