dsebao
6/25/2013 - 12:42 AM

Random images with jQuery (example for Wordpress theme)

Random images with jQuery (example for Wordpress theme)

$(document).ready(function(){
  
  var images = ['image1.jpg', 'image2.jpg','image3.jpg'];
	$('#bg').css({'background-image': 'url(wp-content/themes/mytheme/images/' + images[Math.floor(Math.random() * images.length)] + ')'});

});