javascript 获取指定范围随机数
1 <script type="text/javascript"> 2 function GetRandomNum(Min,Max){ 3 var Range = Max - Min; 4 var Rand = Math.random(); 5 return(Min + Math.round(Rand * Range)); 6 } 7 var num = GetRandomNum(3,10); 8 alert(num); 9 </script>
1 <script type="text/javascript"> 2 function GetRandomNum(Min,Max){ 3 var Range = Max - Min; 4 var Rand = Math.random(); 5 return(Min + Math.round(Rand * Range)); 6 } 7 var num = GetRandomNum(3,10); 8 alert(num); 9 </script>