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
Post a Comment