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>

 

效果图:
JS 随机数_第1张图片
 

 

你可能感兴趣的:(js,随机数)