The N shortcut 2


#1



https://www.codecademy.com/en/courses/web-beginner-en-4hxyb/0/9?content_from=make-an-interactive-website%3Ajquery-events


Oops, try again. It looks like the n key isn't moving to the next article. Remember to remove the 'current' class from currentArticle and place it on nextArticle.


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

$(document).ready(main);


I do not know what the problem is... any help is appreciated


#2

Hi it's mssing part of the if statement

if(event.which === 111) {

this line

$('.current').children('.description').toggle();

shoulld be inside the if statement

if(event.which === 111) {//open the if statement
   //here put it
} //clsoe the if statemen
else if (event.which === 110) {
........

#3

Ok thx. It's working now


#4

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