I want to make a fixed background changes with jQuery. I put the style of body as follows
body {
background-attachment:fixed;
}
Untill now everything is ok and the background is not scrolling, but when I use the jQuery to make it change it start scrolling again.
This is the jquery code :
$(function () {
var body = $('body');
var backgrounds = [
'url(./images/001.jpg)',
'url(./images/02.jpg)','url(./images/03.jpg)','url(./images/04.jpg)','url(./images/05.jpg)'];
var current = 0;
function nextBackground() {
body.css(
'background',
backgrounds[current = ++current % backgrounds.length]);
setTimeout(nextBackground, 5000);
}
setTimeout(nextBackground, 5000);
body.css('background', backgrounds[0]);
});
Can any one help please?