Reputation: 448
I've looked around at how to toggle animate in jquery, but still no luck.. this is what I have, any help would be great.
I have a vertical sidebar that when you click a button (a.mobile-menu-icon) the div slides 250px to the right. I then want it to slide back (-250px;) again when you click the same button.
$('click', 'a.mobile-menu-icon').toggle(function(){
$('#sidebar').animate({
left: '0px;'
}, 500);
},
function(){
$('#sidebar').animate({
left: '-250px;'
}, 500);
});
Upvotes: 1
Views: 260
Reputation: 388316
It should be if jquery < 1.9
$('a.mobile-menu-icon').toggle(function(){
$('#sidebar').animate({
left: '0px;'
}, 500);
}, function(){
$('#sidebar').animate({
left: '-250px;'
}, 500);
});
In 1.9 this particular usage of toggle is removed
Upvotes: 2