I passed the news reader lessons, but my code is not working. PLZ HELP


#1



I passed the news reader lessons, but my code is not fully working. When I click on any of the articles nothing happens. However, when I press o it opens the description. and then, when i press n nothing happens. Can anyone let me know whats wrong with my code so that I may fix it??

var main = function() {
$('.acticle').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';
        nextArticle = currentArticle.next();
        currentArticle.removeClass();
        nextArticle.addclass('.current');
    }
});

}

$(document).ready(main);

Replace this line with your code.

`


#2

Hi @paperboi,

  1. Check your spelling of article on line 2.
  2. In your else if statement inside the keypress event, you need to select elements with the current class using the jQuery selector ($(...)).
  3. ā†‘ in the same else if statement as above, you need to specify which class to remove from currentArticle.

#3

Thank you so much. It was bugging me for the whole day.


#4

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