如何使函数/方法在jQuery中一起工作

时间:2022-05-14 19:46:25

for some reason in the following code the fadein method doesn't work while the first function works perfectly. How do I make them work together?

出于某种原因,在下面的代码中,当第一个函数完美地工作时,fadein方法不起作用。我如何让它们一起工作?

$(document).ready(function(){

    function updown() {
        $("#freccia")
            .animate( {"top": "+=20px"}, 2000, "easeInOutQuad" )
            .animate( {"top": "-=20px"}, 2000, "easeInOutQuad" );
        updown();
    }

    updown();

    $("#frontespizio")
        .hide()
        .fadeIn(2000)
        .delay(2000);
});

1 个解决方案

#1


1  

$(document).ready(function(){    
     updown();
     fadeMe();     
});

function updown() {
    $("#freccia")
        .animate( {"top": "+=20px"}, 2000, "easeInOutQuad" )
        .animate( {"top": "-=20px"}, 2000, "easeInOutQuad" );
}

function fadeMe() {
    $("#frontespizio")
        .hide()
        .fadeIn(2000)
        .delay(2000);
}

#1


1  

$(document).ready(function(){    
     updown();
     fadeMe();     
});

function updown() {
    $("#freccia")
        .animate( {"top": "+=20px"}, 2000, "easeInOutQuad" )
        .animate( {"top": "-=20px"}, 2000, "easeInOutQuad" );
}

function fadeMe() {
    $("#frontespizio")
        .hide()
        .fadeIn(2000)
        .delay(2000);
}