$(function(){ var AryAD = ["title01.jpg", "title02.jpg", "title03.jpg", "title04.jpg", "title05.jpg", "title06.jpg", "title07.jpg", "title08.jpg", "title09.jpg"]; var n = Math.floor(Math.random() * AryAD.length + 1)-1; $('#pagead').css('background','url(images/'+AryAD[n]+') no-repeat center center'); });