Need help on exercise 7


#1

> 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. This is what I keep getting and I'm putting the correct key code but it won't work.


7. The O Shortcut Help
#2

Hi Kincaid,

Would you mind posting your code and a link to the exercise you're on, please?
Thanks :slightly_smiling:


#3

Getting this same issue as well. Seems like everything is right.....

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

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


#4

I was able to correct mine. The issue appeared to be the .click function not being closed before beginning the .keypress function. Here is the corrected script.

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

#5
$(this).addClass9'current');
$(this).children('.description').show();

});

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

This is what I put and it doesn't work


#6

Thanks man I needed the help.