9/10 The n shortcut


#1

Hi, can someone please tell me what I'm doing wrong?

var main = function() {
$('.article').click(function() {
$(this).addClass('current');
$('.description').hide();
$(this).children('.description').show();
$(this).children('description').show();
});
$('.article').removeClass('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');
    }
});

};

$(document).ready(main);

Thank You


#2

Hi Rowen,

You're missing these three lines at the top of main():

$('.description').hide();
$(this).children('.description').show();
$(this).addClass('current');

Then, you need to remove what's now line 11 (originally line 8).
And line 9/originally 6 isn't doing anything and is a duplicate of line 8/originally 5.

I hope this helps! Please let me know if you've got any more questions :)


Also, for future reference, could you please format your code? You can do that by highlighting all of your code while editing/creating a post, and clicking the </> button in the formatting bar above the textarea, or, my preferred method, adding three backticks (`) and an empty line before and after my code.
Thanks!