I have a page where my image will fade in and fadeout effects are there.. The fadein option seems to be some issue as it happens immediatley... Please find my jsfiddle.
Please help
Two things, first fadeIn()
only runs on hidden elements so you need to hide your images initially, second you need to wait for the fadeOut()
animation to complete before animating the next image. This code should work for you, I removed the interval and the count variable:
var $slideshowImgs = $('.slideshow img').hide();
(function fadeSlideshow ($img){
var $next = $img.next();
if(!$next.length)
$next = $slideshowImgs.first();
$img.delay(2000).fadeOut(function(){
$next.fadeIn();
fadeSlideshow($next);
});
})($slideshowImgs.first().show());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.