O Shortcut


#1



This is the message I keep getting, but I don't know what I'm doing wrong, please help!!

Oops, try again.
It looks like the o key isn't opening a description. Remember to
toggle the current article's description inside the event handler. Look
back at the instructions for the code.


var main = function() {
   $('.article').click(function() {
       $('.article').removeClass('current');
       $(.'description').hide();
       
     $(this).addClass('current');
     $(this).children('.description').show();
}); 
};
   $(document).keypress(function(event) {   
    if(event.which === 111) {
        $('.current').children('.description').toggle();
};
});
$(document).ready(main);


#2

Hi Msilver4,

$(.'description')

See the problem there?

Then, the closing curly brace (}) on line 9 is closing your main function early, so you need to move that line down to just before $(document).ready(main); :slight_smile:


#3

Right before me ! :laughing:


#4

@msilver4
If you write

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

you have closed the =main= function
and any following code is not seen as being part of the =main= function.

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

#5

It worked!! Thank you guys so much!


#6

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.