Problem with N shortcut


#1

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.
here's my code:
$(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');
}
});


#2

I don't know what's wrong with this code


#3

Hi Prestont,

Could you please post and format all of your code in app.js?
Thanks!

You can format code by selecting it all while in the post editor, and pressing Ctrl/Cmd + K, or by adding a new line and three backticks (`) before and after your code, like this:


```
<code> will show up properly here
```

#4

var main = function() {
$('.article').click(function() {
...
});

$(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');
}
});

$(document).ready(main);


#5

@prestont Try adding a closing curly brace (}) to close main() right before the last line.
If that doesn't work though, I need your complete code. That means don't cut out parts of it with ... :)