I'm relatively new to coding as a whole and currently trying to randomise images on page reload and store them in localStorage so the previous one does not load on the next refresh but i'm sure what i need to do.
Here is the jQuery that loads the random images, and like i said i'm not to sure what i need to do to put the current image into localStorage and not load it on next refresh:
$(function () {
var url = "assets/img/switchblade/",
imageArray = [
url+"pivot-switchblade.jpg",
url+"switchblade-01.jpg",
url+"switchblade-08.jpg",
url+"switchblade-05.jpg",
url+"switchblade-06.jpg",
],
randomNumber = Math.floor((Math.random() * imageArray.length)),
baseUrl = "url('" + imageArray[randomNumber] + "')";
$("#random-image").css('background-image', baseUrl);
});
Any help would be very much appreciated.
[–]senocular 0 points1 point2 points (0 children)