I have a random background set to a div. I was wondering if it was possible for when the background changes it will display a different background every time and not duplicate from within my image directory.
Any help is hugely appreciated.
$(function() {
var images = ['1.png', '2.png', '3.png'];
$('#sectionhero').css({
'background-image': 'url(bgimages/' + images[Math.floor(Math.random() * images.length)] + ')'
});
});
Aucun commentaire:
Enregistrer un commentaire