Uncaught SyntaxError: Unexpected token }


#1

Hi! I keep getting the unexpected token message, but can't figure out what's wrong...

var main = function () {
$('.article').click(function() {
$('.article').removeClass();
$('.description').hide();

$(this).addClass('current');
$(this).children('.description').show();

});

$(document).keypress(function(event) {
if(event.which === 111)

});

$(document).ready(main)


#2

Hi Juliesoreng,

Your problem is right here: :slightly_smiling:


You're not closing your if statement, only your $(document).keypress(...); part. You're also not closing your main function. Both take a closing curly brace (}) to close them. So make that part of code ↑ look like this:

  $(document).keypress(function(event) {
    if (event.which == 111) { // ← open your if statement
      // ...
    } // ← then close it
  });
}; // ← close main

$(document).ready(main); // don't add this line again; you already have
                         // it. I'm just showing it as a reference point

#3

Thank you zystvan!! Haha, I can't believe it was so simple.

I think I haven't completely gotten the open-close thing.. But thanks a lot!