I really don't see the error in my code. Please help


#1
var main = function () {
  $('.icon-menu').click(function() {
    $('.menu').animate({
      left: '0px'
    }, 200);

    $('body').animate({
      left: '285px'
    }, 200);
  });
  
  $('.icon-close').click(function() {
    $('.menu').animate({
        left: '-285px'
    }, 200);
    
    $('body').animate({
      left: '0px'
    }, 200);
  });
};

#3

Hey there, @bandit!

You forgot about the .ready() at the end of your file.
Just add $(document).ready(main); at the very end of your file and it should work :slight_smile:

Should look like this then:

var main = function() {
  $('.icon-menu').click(function() {
    $('.menu').animate({
      left: "0px"
    }, 200);

    $('body').animate({
      left: "285px"
    }, 200);
  });

  $('.icon-close').click(function() {
    $('.menu').animate({
      left: "-285px"
    }, 200);

    $('body').animate({
      left: "0px"
    }, 200);
  });
};

Hope I could help you :slight_smile:
If you got further questions, feel free to get in touch with me :smiley:
Make sure to mark my post as solution, so others which face the same
issue will be able to take it as a reference :wink:
Greez, 0xB4DC0DED


#4

@bandit

++++++++++ structure P u s h M e n u function
The structure of your =main= Function should look like....

  var main= function() {
     $('.icon-menu').click( function() {
           //Your animation
     });

     $('.icon-close').click( function() {
           //Your animation
      });
   };
 $(document).ready(main);

explanation of the push-menu setup
https://www.codecademy.com/forum_questions/55b3d3c1d3292f529b00005e


#5

Thanks a lot that was my problem. :grin:


#6

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.