I am currently building a site whereby they would like each image on load to display different images. I have so far been able to target these and randomise them but it is applying the same image to all of the items. If you could see where I'm going wrong it would be great
var description = [
"http://ift.tt/1geejaY",
"http://ift.tt/K6GcHn",
"http://ift.tt/18Dncvt"
];
var size = description.length
var x = Math.floor(size*Math.random())
$('.item img').each(function() {
if($("img").hasClass("people")) {
$(this).attr("src",description[x]);
}
});
Aucun commentaire:
Enregistrer un commentaire