Interactive menu won't close, missing )


#1

Hi,

When I add the menu close function I get an error Uncaught SyntaxError: missing ) after argument list.

I can't see what's wrong.

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

Any help would be appreciated, thanks


#3

Hi Darrenlawes,

Which exercise are you on?


#4

The first problem is in this line:

$('body'.animate({

You have to close your selector with ), just like you did before:

$('body').animate({

After this change your code with proper formatting should look like this:

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

Do you see a problem now?

You have to close main function just before $(document).ready(main);.


#5

Thats solved it - I can't believe I missed that " )" I must of gone through the code characters 10 times and still missed it!

Thanks


#7

You're very welcome :smile: