I keep struggling with the .animate function

I keep stuggling with the animate function. in combination with the .toggle function. I simply try to make a div slide from right to left and visa versa on click. This is what I have:


	var w = $('.content').width();
  $('#toggle').toggle(function() {
    $('div.content').animate({left: -600}, 600, function(){
		return false;
  }, function() {
    $('div.content').animate({left: 0}, 900, function(){
		return false;


<div id="content" class="content">
	<div class="header">
  	<div class="close"><a href="##" id="toggle">Close</a></div>

When opening the page the content div slide automatically to the left and the toggle anchor slides to the right. What am I doing wrong, and can someone please explain me the .animate/.toggle functions in more detail.

Thank you in advance

Hi donboe,

Which version of jQuery are you using?
jQuery’s Toggle Event function has [URL=“https://github.com/jquery/jquery-migrate/blob/master/warnings.md#jqmigrate-jqueryfntogglehandler-handler-is-deprecated”]been removed as part of version 1.9. which could account for your error.

Oh my. That was it indeed. I was struggling the entire morning. Thank you so much Pullo. :tup: