Can't get the o function to work


#1

I’ve been trying to figure this out for close to an hour, my code works all the way up to step 7 and now I can’t get it to work and the toggle function has stopped. It says I have an unexpected identifier but can’t find it. Anyone able to help me? I’ve read other questions like this one but don’t couldn’t make heads or tails if it would help me.

chipvar main = function(){
('.article').click(function() { (’.article’).removeClass(‘current’);
('.description').hide(); (document).keypress(function(event) {
if(event.which === o) {
$(’.current’).children(’.description’).toggle();
}
});
}

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

};

$(document).ready(main);


#2

@dapperdan95
You have pasted-in
your document =keypress= Eventhandler

$(document).keypress(function(event) {
   if(event.which === o) {
       $('.current').children('.description').toggle();
   }
 });

into the middle of your
article =click= Eventhandler

$('.article').click(function() {
   $('.article').removeClass('current');
   $('.description').hide();
   $(this).addClass('current');
   $(this).children('.description').show();
 });

and with the pasting also added an extra closing-curly-bracket-} !!!

####===========================================================

the structure of our main-function looks like:

var main = function() {
     //BEGIN of main function-body 
    //
    //The CLICK event-handler is

    $('.article').click(function() {

     });

     //now comes the KEYPRESS event-handler

     $(document).keypress(function(event) {

       });
   //END of main function-body
   };

  $(document).ready(main);