5. Open the menu


#1

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

$(document).ready(main);

Hey!

This code is working but I was just wondering if my understanding of it is correct as initially I was confused about why the animate values for the menu and body were set to 0px and 285px, respectively. Initially I thought that the numbers were the number of pixels added on but that didn't make any sense to me. Instead, is the 0px 'position' the left edge of the page, and what happens is that the menu moves to the 0px 'position' and the body moves to the 285px 'position' to the right of the screen.

Thanks!


#2

Hey Tyoungg,

You're understanding how it works correctly :slightly_smiling:
Have fun with the rest of the course, & feel free to ask any questions you may have on here!