> I'm relatively new to jquery, and i'm trying to find a way to toggle a > simple animation? > > At the moment I have this, which moves a div 400px to the left upon > clicking a link. Pretty straight forward. > > $(document).ready(function(){ > $(".slide").click(function () { > $("#slider").animate({marginLeft: "-400px"}, 1000, > "easeInOutQuad") > }); > }); > > I want the link with the "slide" class to toggle that div to animate > 400px to the left on click, and then animate it back to 0px upon > another click. Really just toggle between those two positions. > > I've tried searching tutorials, and plugins, but I can't seem to find > anything to for something I though would be relatively simple. > > Any help would be much appreciated! Thanks.
$(document).ready(function(){ $(".slide").toggle( function () { $("#slider").animate({marginLeft: "-400px"}, 1000, "easeInOutQuad") }, function () { $("#slider").animate({marginLeft: 0}, 1000, "easeInOutQuad") } ); });