how do i randomly rotate the images without refreshing the page with setTimeout??
js:
var bannerImages = new Array( );
bannerImages[0] = "Banner1.jpg";
bannerImages[1] = "Banner2.jpg";
bannerImages[2] = "Banner3.jpg";
bannerImages[3] = "Banner4.jpg";
var randomImageIndex = Math.round( Math.random( ) * 3 );
document.write( "<img alt=\"\" src=\"imgs/" + bannerImages[randomImageIndex] + "\">" );
`
Just change the src attribute of the image:
Try it: http://jsfiddle.net/A3v8w/
Using JqueryRotate plugin, we can do it easily & more smoothly, with only 1 image
For e.g-
http://jsfiddle.net/73pXD/
Ref: jquery-plug-in & codes here .