My array var myImages = [];
that once i've console.log()
the array (I push items in into it above) I get this back:
["01_img"]
["02_img"]
["03_img"]
["04_img"]
["05_img"]
Then onClick
I change the background of a div
to have a background image from the array.
$('.div_content').css('background-image', 'url(https://url/path/images/' + myImages + '.png)');
How do I change make it, so the background image I have changes onClick
.
I tried as per example I found, but to no prevail:
$('.btn').on('click', function(){
var myIndex = 1;
myIndex = (myIndex+1)%(myImages.length);
$('.div_content').css('background-image', 'url(https://url/path/images/' + myIndex + '.png)');)
});
Any help is appreciated, thanks.