The o shortcut


#1



The o shortcut
What's the error in this code?

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


#2

Hi @creat,

Try putting your keypress event listener inside your main function.


The n shortcut 2
#3

it's already inside.
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();
} //*this is the ending bracket for the key pressed event*//
}); //*this is the ending brackets for the main function*//


#4

@creat Check your closing curly braces (}), it's not inside the main function. You're also missing a closing parenthesis ()) for the $('.article').click(...); piece.


#5

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