Can open menu fine, but when more code added to close menu, it no longer works at all


#1

Very new to this so probably something obvious! Any help appreciated.

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);
  });
};

$(document).ready(main);

#2

Hi Ryan,

Can you spot the problem there?

Hint

You're missing a dot (.). That part should look like this instead:

$('.menu').animate


#3

Missing dot! I'd been staring at it for so long I couldn't see it.

Is there any method for finding missing things like that or is it simply knowing it all like the back of your hand?

Many thanks.


#4

Mainly that it's a common mistake here on the forums, so it's one of the first things I check :smile:
As you write more and more code, you'll make fewer mistakes and get better at catching them, but they'll be harder to catch, so you might never be able to tell a difference, but you will be getting better :slightly_smiling:


#5

Thanks for your help!

Last coding I did was on my Commodore 64 many years ago. :smile: