I am trying to change the background every second with the following code, but I am having trouble including CSS properties like centering, covering, and positioning the image properly. How can I modify this function to incorporate these settings for the background images in the CSS?
$(function() {
var body = $('body');
var backgrounds = ['url(http://static.jsbin.com/images/jsbin_static.png)', 'url(http://static.jsbin.com/images/popout.png)'];
var current = 0;
function displayNextBackground() {
body.css(
'background',
backgrounds[current = ++current % backgrounds.length]
);
setTimeout(displayNextBackground, 1000);
}
setTimeout(displayNextBackground, 1000);
body.css('background', backgrounds[0]);
});