I’m having trouble with javascript animate. I’ve got one div that toggles to show a form, and another div that moves to the left when the form slides in. I’m trying to get the div to move back to the right when the form toggles to hide.
I’ve got it on JSFiddle. Any thoughts as to why it’s not working?
You are using assignments instead of comparisions. This is wrong:
It should be:
Also direction should be initialized:
And in order to move the element back to its original position, you should animate margin back to 0 instead of +160.
http://jsfiddle.net/KWSvy/6/