Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
jquery sequence fadeOut and then remove

I try $('somediv').fadeOut.remove(); but it only remove it, bang... it dont wait for the nice fadeOut, and THEN remove

why.. how to respect fadeout, and then remove..

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Use a callback:

$('somediv').fadeOut( function() { $(this).remove(); });

The code in the callback function you're passing to fadeOut()(docs) will not execute until the animation is complete.

Example: http://jsfiddle.net/p2LWE/

An alternative would be to queue()(docs) the remove()(docs) , but I think the callback is better.

$('somediv').fadeOut()
            .queue(function(nxt) { 
                $(this).remove();
                nxt();
            });
over 4 years ago · Santiago Trujillo Relatório

0

Here is the simple way,

$('#somediv').fadeOut(300,function(){ $(this).remove(); })};

or

$('#somediv').fadeOut("slow",function(){ $(this).remove(); })};
over 4 years ago · Santiago Trujillo Relatório

0

With jQuery chaining, one part of the chain doesn't wait for other parts to end if there's a time-based component. So when you want something to happen when another thing finishes, you'll need to use callbacks. In this case, you call fadeOut() with a parameter for what function to run when it's done. Like so:

$('#somediv').fadeOut(function(){ $(this).remove(); })};

So when fadeOut() is done (and you can add a leading parameter that dictates how long that'll take, either in miliseconds or 'fast', 'normal', or 'slow'), it'll call the function, which does the remove().

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda