JQuery animation

Posted by Ravindra Soni on Stack Overflow See other posts from Stack Overflow or by Ravindra Soni
Published on 2010-04-30T06:11:33Z Indexed on 2010/04/30 6:17 UTC
Read the original article Hit count: 229

Filed under:

I am using following code for animation using jquery. When I click on a list element, the corresponding div slides down and opacity goes to '1'. When I click other list element, the previous one goes up and fades, and the next one come down.

var id_prev;
 var id_new;
 $("#tag ul li ").click(function(event){
  var i = $(this).index()+1;
  var id_new="#person"+i;
  if(id_new != id_prev){
   $(id_prev).animate({top:'300px',opacity:'0'},500);
   $(id_prev).delay(200).css({'z-index':'0'});
   $(id_new).delay(200).css({'z-index':'300'});
   $(id_new).delay(200).animate({top:'300px',opacity:'0'},500);
   $(id_new).delay(200).animate({top:'330px',opacity:'1'},500);
   id_prev = id_new;
  }

});

© Stack Overflow or respective owner

Related posts about animate