日常小记

JavaScript实现随机显示图片

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];

}
id:myPicture为你想要修改的img标签的id的值

回复

This is just a placeholder img.