js 随机数

<script type="text/javascript">
// function scr_img(){
      ////二维码
      var scr_img = new Array()
      scr_img[1] = '1.jpg';
      scr_img[2] = '2.jpg';
       // 海报
      var scr_img_a = new Array()
      scr_img_a[1] = '1.jpg';
      scr_img_a[2] = '2.jpg';
     
      m = scr_img.length -1;
      n = 1
      var random = Math.floor(Math.random()*(m-n+1)+n);
      // if(scr_img[random] == undefined || scr_img_a[random] == undefined ){
      //        random = 1;
      //   }
      var scr_a_random = "../img/" + scr_img[random] //二维码
      var scr_b_random = "../img_a/" + scr_img_a[random] // 海报
     // $('#scr_a').attr('src',scr_a_random);//把src属性更改为'1.jpg';
     // $('#scr_b').attr('src',scr_b_random);//把src属性更改为'1.jpg';
    // document.write(scr_a_random); 
    document.write(random); 
    // document.write("++++"+scr_img.length+"++"); 

    // document.write(scr_b_random); 
// }
</script>

 

posted on 2018-12-17 14:03  ||子义  阅读(188)  评论(0编辑  收藏  举报

导航