7. O shortcut - my code works why isnt it letting me pass?


#1

Here is my code:

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

When I press O, it toggles the description to open and close. Yet it gives me an error saying it's not. wtf


#2

Heres the full code:

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

};

 $(document).ready(main);

#3

whoops i fixed it...The keypress should be AFTER the click function.


#4

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