欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS簡單隨機數生成方法

 更新時間:2016年09月05日 12:01:26   作者:onestopweb  
這篇文章主要介紹了JS簡單隨機數生成方法,通過javascript自定義函數演示了隨機數的生成方法,需要的朋友可以參考下

本文實例講述了JS簡單隨機數生成方法。分享給大家供大家參考,具體如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>隨機數</title>
</head>
<body>
<script type="text/javascript">
function Randnum(value){
  var s=1000;
  var d=500;
  if(value=='b'){
    document.write(s+parseInt(500*Math.random()));
  }else{
    document.write(d+parseInt(500*Math.random()));
  }
}
</script>
<script>Randnum();</script>
</body>
</html>

效果圖:

更多關于JavaScript算法相關內容感興趣的讀者可查看本站專題:《JavaScript數學運算用法總結》、《JavaScript排序算法總結》、《JavaScript遍歷算法與技巧總結》及《JavaScript數據結構與算法技巧總結

希望本文所述對大家JavaScript程序設計有所幫助。

相關文章

最新評論