The N Shortcut 2 Problem


#1

Hey everyone, I'm doing the N shortcut 2 and its telling me to make sure to "remove the 'current' class from currentArticle and place it on nextArticle." which as far as i can see i have done.

Can someone look at my code and let me know where it is I have gone wrong?;

  • Thanks

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

@nathanersser,
An IF ELSE-IF statement structure look like

if ( condition ) {
   //IF code-block
}
else if ( condition ) {
  //ELSE-IF code-block
}

#3

@leonhard_wettengmx_n

So where in the "IF" & "ELSE IF" Statement have I gone wrong? I cant see the problem with the structure at all

Thanks


#4

@nathanersser,

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

#5

3 posts were split to a new topic: What's wrong with my code? (N Shortcut 2)