I tried to create a simple css background-image transition using the fadeIn fadeOut jQuery function. I used the description on the jquery page to create mine. Now it works very well, but I would like to have some kind of crossover. At the moment, it just fades to white and white. Here is the code:
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
var imgArr = new Array(
'img/bg_1.jpg',
'img/bg_2.jpg'
);
var preloadArr = new Array();
var i;
for(i=0; i < imgArr.length; i++){
preloadArr[i] = new Image();
preloadArr[i].src = imgArr[i];
}
var currImg = 1;
var intID = setInterval(changeImg, 10000);
function changeImg(){
$('#head_bg').fadeOut('slow', function(){
$(this).css('background','url(' + preloadArr[currImg++%preloadArr.length].src +') top center no-repeat');
}).fadeIn('slow');
}
});
</script>
Hope someone knows the solution :)
Now I am porting it with switching two different background classes, providing the same result.
NEW !!! NEW !!! NEW !!! NEW !!! NEW !!!
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
$('#head_bg').delay(4000).animate({opacity: 0}, 2000, function(){
$('#head_bg').removeClass().addClass('bg2').animate({opacity: 1}, 2000);
})
});
</script>
Now I have two ways to do the same;) .. But I still don’t know how to do this with two separate divs and make them visible above each other and rotate them. Sorry, but I don’t understand how .. can someone give me a quick example, please?