The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Slide Animation: Sliding Back
The javascript animation below moves the .whole CSS class 200px (from left to right) when I click a button named .mobile-btn.
What would I add to this script to make the animation slide back when the button is clicked again?
http://jsfiddle.net/ct2Wd/
<script type="text/javascript"> $('.mobile-btn').click(function(event) { value = $('.whole').css('right') === '200px' ? 0 : '200px'; $('.whole').animate({ left: value }); }); </script>