javascript - jquery how to toggle this specific animation? -


so want toggle animation in jquery found hard find way.

$( "#console" ).animate({height: "20px"}); 

you can set height of element in variable , use animate. need save toggle state having animation without bug.

var firstheight = $("div").height();  $("div").click(function(){      $(this).stop();      if (!$(this).data("animatetoggle"))          $("div").data("animatetoggle", 1).animate({height: "200px"});      else                 $("div").removedata("animatetoggle").animate({height: firstheight});  });
div {      width: 100px;      height: 100px;      background: green;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div></div>


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -