I am using HTML5 Scratch Card plugin and dont know how I can render random backgrounds with javascript.Here is the code
window.onload = function() {
createScratchCard({
'container':document.getElementById('circle'),
'background':'assets/images/demo2-circle-background.png',
'foreground':'assets/images/demo2-circle-foreground.png',
'percent':100,
'coin':'assets/images/coin2.png',
'thickness':18,
});
}
So with this default structure how I can render random 2, 3 images and show one every time, show randomly>
You could set all your file's names into an array and pick one randomly each time.
To make sure your user won't get the same value every time they come to your page, the only solution is to save it somewhere on their side. For this you could use cookies, or as chosen in the above example localStorage :