i have following script like :
/* jshint loopfunc:true */
var url = [
"http://protiumdesign.com/wp-content/uploads/2015/04/Material-Design-Background-1024.jpg",
"http://i.imgur.com/wt4NRqA.jpg",
"http://i0.wp.com/thezinx.com/wp-content/uploads/md-6.png"
];
$(document).ready(function() {
changeBack();
function changeBack() {
for (var i = 0; i < url.length; i++) {
$('#elem').fadeTo('slow', 0.3, function() {
$(this).css('background-image', 'url(' + url[i] + ')');
}).fadeTo('slow', 1).delay(1000);
}
changeBack();
}
});
the function above for change the background image dynamically but the array is undefined within the function, how to fix that , thank you
this is the fiddle : Here