" images/tiger.jpg "
界说一个图片数组,,生成一个随机数对应数据索引。
window.onload = choosePic;
function choosePic() {
var myPix = new Array("images/lion.jpg","images/tiger.jpg","images/bear.jpg");
var randomNum = Math.floor((Math.random() * myPix.length));
document.getElementById("myPicture").src = myPix[randomNum];
}
js随机显示图片
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31939.html