Jquery incrementing number +1 0n page refresh.
- by sameast
Hi guys i am trying to modify this code here.
$(document).ready(function() {
var randomImages = ['img-1','img-2','img-3','img-4'];
var rndNum = Math.floor(Math.random() * randomImages.length);
$("div#bg-image").css({ background: "url(http://example.com/images/" + randomImages[rndNum] + ".jpg) no-repeat" });
});
This works fine and gives me a random image each time which is great but what i need is for the image to increment +1 each time on page refresh.
This is because sometimes i can refresh 3 times and will still get the same image show when using Math.random(). I need to cancel the random and set +1 each time.
Any help