Search code examples
javascriptjqueryhtmlfade

Starting jquery fadeToggle hidden


I want to use fadeToggle to fade in and out some images automatically. It's working, but all the images start 'faded in', and I would like them to start invisible, so that they appear one by one. Thanks in advance!

    $(function () {
function run_animation($element, delay, duration) {
    $element.delay(delay).fadeToggle(duration, function () {
        run_animation($element, delay, duration);
    });
}
run_animation($('.pointer1'), 2000, 1000);
run_animation($('.pointer2'), 2500, 1000);
run_animation($('.pointer3'), 3000, 1000);
run_animation($('.pointer4'), 3500, 1000);
run_animation($('.pointer5'), 4000, 1000);

Solution

  • Did you try by hiding images using CSS? Try display:none and if required you can call animation after show().