The O key


#1

Hello there,

I cannot figure out what i did wrong in the exercise, the o button works but i get the error:

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

I cannot find the error in the code :frowning:

regards,


#2

HI the $(this).children('.description').show() { .. }); shouldn't be inside the $(document).keypress(function(event){ ..}); so your code should be like that

var main = function() {
    $('.article').click(function(){ 
       ...
    });
    $(document).keypress(function(event){
       ...
    });
};
$(document).ready(main);

#3

Thanks alot! I see where I went wrong.

have a nice day.


#4

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