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); 

I cannot find the problem, help appreciated.


#2

Hi Blondesquirrel,

I cannot find the problem

Please post the error message you're getting so we can help you.

As a start, try replacing the double quotes (") you're using in selectors ($(...)) with single quotes (').


#3

This is what it says:
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.


#4

@blondesquirrel Your code works fine for me, so I'm not sure why it's throwing an error. Could you try refreshing the page or switching browsers, please? :slight_smile:


#5

Refreshing the page worked


#6

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