jQuery nach animate ausführen

hoctar

Erfahrenes Mitglied
Hallo :)
ich möchte gerne nach beenden einer animation eine andere animation ausführen

Code:
$('.con').animate({opacity: "hide"}, {duration: "slow"});
$('#test).animate({opacity: "show"}, {duration: "slow"});

ich habe es bereits mit "complete" ausprobiert, nur leider wird für jedes .con element die zweite animation ausgeführt
 
Dort steht:
A function to be executed whenever the animation completes, executes once for each element animated against.

"executes once for each element"
ich möchte das die letzte animation nur einmal nach beenden der ersten aufgerufen wird
 
Ahso...sorry, hab ich nicht wahrgenommen, dass es um das "einmalige" geht :)

Das wäre bspw. eine Möglichkeit:
Code:
$('.con').animate(
  {opacity: "hide"}, 
  {duration: "slow",
   complete:function()
            {
              if(this==$('.con').get(0))
              {
                $('#test').animate({opacity: "show"}, 
                                   {duration: "slow"});
              }
            }
   }
);

Einfach gucken, ob das die Callback-Funktion auslösende .con das 1. .con im Dokument ist...
Code:
if(this==$('.con').get(0))
wenn ja, dann 2. Animation.
 
Zurück