I want to change the background image using slow animation, but its not working
$('body').stop().animate({background:'url(1.jpg)'},'slow');
Is there something wrong with the syntax!!
I want to change the background image using slow animation, but its not working
$('body').stop().animate({background:'url(1.jpg)'},'slow');
Is there something wrong with the syntax!!
I would use a faux div to cover the background as a fixed element and then animate that element i.e:
The way to achieve this may be to onclick add a new class with the background image in. Then animate this? Or fade out the image to reveal a new one?
From the jQuery documentation:
Source: http://api.jquery.com/animate/
Here is how I did it:
You can get a similar effect by fading the image opacity to 0, then change the background image, and finally fading the image back in again.
This will require a div, behind everything else on your page which is as wide as the body.
You can make it as wide as the page using CSS:
And then animate it's properties.
You could get more of a crossover effect, by having a second background div on top of this one, which you can then fade in.
You can't animate the adding/replacing of a background image. The URL is either there or not. There's no in between state.