JS产生四位随机数的方法

<script>
var charactors="1234567890";

var value='',i;

for(j=1;j<=4;j++){

i = parseInt(10*Math.random());  

value = value + charactors.charAt(i);

}

document.write(value);

</script>

 

 

<script>value =Math.floor(Math.random()*4000+1000);document.write(value);</script>

posted @ 2016-04-25 16:55  Jweib  阅读(7181)  评论(0编辑  收藏  举报