TheN Shortcut 2


#1



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) {
      $('.description').hide();
      $('.current').children('.description').toggle();
    } else if(event.which ===110) {
      var currentArticle = $('.current');
      var nextArticle = currentArticle.next();
      
      currentArticle.removeClass('current');
      nextArticle.addClass('current');
    }
  });
}

$(document).ready(main);


#2

Hey @mstobbe31,
after checking your code, I noticed that you got a little "error" in it.

Just remove the first line in the if-statement for your o-key event-handler out of your code.
(Which is $('.description').hide(); )

You don't need it, cause toggle(); automatically hides/shows the description, based on the previous state (hidden or shown).

Hope I could help you :slight_smile:


#3

Hi @mstobbe31,

What's the error message you're getting?