'The o shortcut'


#1



https://www.codecademy.com/courses/web-beginner-en-4hxyb/0/7?content_from=make-an-interactive-website%3Ajquery-events#


Can anyone please point out exactly what's wrong with my code? I keep getting following error message.

"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."

Thanks in advance.


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 the $(document).keypress(function(event) shoudn't be inside

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

#3

@wizmarco Thank you! :slight_smile: Solved!


#4

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