I have an element figure with a series of images inside:
<figure class="MiniModImgSlider">
<img src="img01.jpg" alt="img01">
<img src="img02.jpg" alt="img02">
<img src="img03.jpg" alt="img03">
<img src="img04.jpg" alt="img04">
<img src="img05.jpg" alt="img05">
</figure>
Note: Images are with display: none.
I want to retrieve the path of each image and assign it to the background of the figure element every 3 seconds. For this I made this script:
var imgs = $(".MiniModImgSlider img").map(function()
{
return $(this).attr('src');
});
for (var i = 0; i <= imgs.length; i++)
{
setInterval(function()
{
$(".MiniModImgSlider").css('background-image', 'url('+imgs[i]+')');
},1000);
}
But instead of assigning the path of the image the script returns undefined! How can I resolve this?