Dropdown Menu Function Help


#1
  1. Open Menu

I just finished this exercise, but there is one thing that confuses me.

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

Above is the code I used, but I wonder why I can't just do:

var main = function(){
    $('.icon-menu').click(function(){
        $('.menu').animate({left: '285px'}, 200); // here*
    }); 
}
$(document).ready(main);

*it seemed to work fine using the last mentioned code. Was there perhaps something that wouldn't work in that case?
It took out the menu the way it should, at least from what I could tell.

So please let me know what the reason is that you may be supposed to use the first mentioned code instead.

Thanks!


#2

Never mind, I solved it.
For whoever else who gets the problem.

The difference is that adding the body code moves the whole page along with the dropdown(sidedrop?) menu.
So one could basically skip that if prefered so when building a site.