首页 > 代码库 > 利用数组更新图片

利用数组更新图片

<script type="text/javascript">
var bannerImages=new Array();
bannerImages[0]="Banner1.jpg";
bannerImages[1]="Banner2.jpg";
bannerImages[2]="Banner3.jpg";
bannerImages[3]="Banner4.jpg";
bannerImages[4]="Banner5.jpg";
bannerImages[5]="Banner6.jpg";
bannerImages[6]="Banner7.jpg";
var randomImageIndex=Math.round(Math.random()*6);
document.write("<img alt=\"\" src=http://www.mamicode.com/""+bannerImages[randomImageIndex]+"\">");
</script>

利用数组更新图片