After the animation I want to remove the block from the page. Those. first bring to opacity = 0, then make display = none

Code:

$("#go").click(function(){ $("#block").animate({ opacity: 0.0 }, 500 ); $("#block").hide(); }); 

immediately executes hide (), apparently in parallel. How to make perform sequentially?

    1 answer 1

     $("#go").click(function(){ $("#block").animate( { opacity: 0.0 }, 500, function(){ $("#block").hide(); } ); }); 

    or:

     $("#go").click(function(){ $.when( $("#block").animate({ opacity: 0.0 }, 500) ).then(function(){ $("#block").hide(); }); }); 

    by the way, .animate({ opacity: 0.0 }, 500) equivalent to .fadeOut(500)

    • With when the solution is crooked - Snow
    • one
      facts disagree with you - Specter