问题
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);
回答1:
Did you try by hiding images using CSS? Try display:none
and if required you can call animation after show()
.
来源:https://stackoverflow.com/questions/15753361/starting-jquery-fadetoggle-hidden