$(document).ready(function() { arrayOfImg = ["http://24.media.tumblr.com/tumblr_mc9tpsX8Up1rfygheo1_250.jpg", "http://25.media.tumblr.com/tumblr_mczqxjE6yL1rfygheo1_250.jpg", "http://24.media.tumblr.com/tumblr_mczqzbiHSg1rfygheo1_250.jpg"]; // place all links here arrayOfHref = ["http://inkperweek.tumblr.com/post/34071658607/traxex-the-drow-ranger-by-aj-banda", "http://inkperweek.tumblr.com/post/35025838536/week-9-vampire-vampira-by-aj-banda", "http://inkperweek.tumblr.com/post/35025918118/week-10-cemetery-finish-line-by-aj-banda"]; var numberRand = Math.floor(Math.random() * arrayOfImg.length); $("#rotatingHref").attr("href", arrayOfHref[numberRand]); $("#rotatingImg").attr("src", arrayOfImg[numberRand]); console.log(numberRand); console.log($("#rotatingImg").attr("src")); });
<div id="pagiImg"> <a id="rotatingHref" href="http://inkperweek.tumblr.com/post/34071658607/traxex-the-drow-ranger-by-aj-banda" target="_blank"> <img id="rotatingImg" src="http://24.media.tumblr.com/tumblr_mc9tpsX8Up1rfygheo1_250.jpg" /> </a> </div>
#pagi{ text-decoration:none; font-weight:bold; background-color:steelblue; width:200px; color:#ffffff; text-align:center; } #pagi a{color:#ffffff;text-decoration:none;font-weight:bold;} #pagiImg{border:1px solid steelblue;width:198px;height:400px;} #pagiImg img{width:198px;height:400px;}