/* 自定义函数 */ function GetRandomNum(Min,Max){ var Range = Max - Min; var Rand = Math.random(); return(Min + Math.round(Rand * Range)); } /* 调用函数 */ var num = GetRandomNum(4,10);
JS 输出指定范围内的随机数
原文:https://www.cnblogs.com/phpfensi/p/8984916.html