Previous Keyword


#1

Since we have a keyword defined for next, it seems normal to have one for previous.
For this I have defined the event.which===112 (for P keyword). Rest of the code bellow.
What am I doing wrong?

var main=function() {
$(".article").click(function(){
$('.description').hide();
$('.article').removeClass('current');
$(this).children('.description').show();
$(this).addClass('current');
});

$(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');
}
else if (event.which===112) {
var currentArticle=$('.current');
var previousArticle=currentArticle.previous();
currentArticle.removeClass('current');
previousArticle.addClass('current');
}
});
};

$(document).ready(main);


#2

@mazualx,
Have a read
https://api.jquery.com/prev/