Hi I have wrote some jQuery but for some reason the fading isnt working
$(document).ready(function () {
var img_array = [1, 2, 3, 4],
newIndex = 0,
index = 0,
interval = 7500;
(function changeBg() {
// newIndex = Math.floor(Math.random() * 10) % img_array.length;
// index = (newIndex === index) ? newIndex -1 : newIndex;
index = (index + 1) % img_array.length;
$('.main-wrapper').css('backgroundImage', function () {
$('#cycler').fadeIn({
backgroundColor: 'transparent'
}, 0, function () {
setTimeout(function () {
$('#cycler').fadeToggle({
backgroundImage: 'url(http://dev.test.co.uk/Content/H/images/bg1.png)'
}, 2500);
}, 4000);
});
return 'url(http://dev.test.co.uk/Content/H/images/bg' + img_array[index] + '.png)';
});
setTimeout(changeBg, interval);
})();
});
can someone shed some light on this please
HTML is only really this theres some content in the middle but just some text
<section id="cycler" class="main-wrapper"></section>
and css is:
#cycler{
position:relative;
}
#cycler img{
z-index:1
}
#cycler img.active{
z-index:3
}
.main-wrapper
{
overflow-x: auto;
margin-left: auto;
margin-right: auto;
height: 1822px;
background-image: url(../H/images/bgone.png);
background-size: cover;
background-repeat: no-repeat;
}
any help is good
Thanks