9/10 9. the n 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) {
$('.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

@shayla15,

the structure of our main-function looks like:

var main = function() {
     //BEGIN of main function-body 
    //
    //The CLICK event-handler is

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

     });

     //now comes the KEYPRESS event-handler

     $(document).keypress(function(event) {

       });
   //END of main function-body
   };

  $(document).ready(main);