I just want to move a div when the user chooses to. When the user clicks on a link, the div appears, moving from right to left. Then there is another link inside the div, when the user clicks on it, the div should move to left to right and disappear.
Following is the jQuery code I’ve tried:
$('#show').click(function(e){
e.preventDefault();
$('div').show().animate({ 'left': 0 }, 300;
});
$('#hide').click(function(e){
e.preventDefault();
$('div').animate({'left': 2050}, 300,function() {$('div').hide()});
});
Fiddle also attached, http://jsfiddle.net/sameerast/JNBAn/
As noted above, this just needs a comma on the 4th line, then the fiddle starts working:
As a side note, I find the JavaScript Console in Chrome to be very helpful in this regard…check it out through View -> Developer -> JavaScript Console (in this case it was showing an unexpected ; error because of the missing parenthesis).