Your test is only performed once when the document is loaded. You should use the
toggle function to swap between the two actions:
- $(function() { // Shorthand for $(document).ready(function() {
- $('#toggle').toggle(function() {
- $('#ribbon').animate({marginTop: '0px'}, 1700);
- }, function() {
- $('#ribbon').animate({marginTop: '-300px'}, 1700);
- });
- });