开发者

Animate image opacity from 0 to 100 and back to 0

开发者 https://www.devze.com 2023-01-30 05:30 出处:网络
I have one image which is stacked on top of another one. I am trying to animate the top image opacity to 0 and then back to 100 and then again to 0. This should continue in a loop. Is there a way i ca

I have one image which is stacked on top of another one. I am trying to animate the top image opacity to 0 and then back to 100 and then again to 0. This should continue in a loop. Is there a way i can achieve it ?? Please help..

$('.bannerHove开发者_如何学Gor').animate({
    opacity: 0.25
  }, 5000, function() {
  });


We can create a simple recursive function that calls jQuery's fade function, and when complete, call itself again using the callback supplied by the fade function. With jQuery 1.4.4's fadeToggle function, it can be done as simply as:

var b = $('#block');
function fade(){
    b.fadeToggle(1000, fade);
}
fade();

See: http://www.jsfiddle.net/yijiang/FnBgL/ for a simple example

0

精彩评论

暂无评论...
验证码 换一张
取 消