7. The o shortcut - SOLVED


#1



I'm on step "7. The o shortcut"


I get the following error: "Oops, try again.
It looks like the o key isn't opening a description. Remember to
toggle the current article's description inside the event handler. Look
back at the instructions for the code."

However, the click function has stopped working as well! Please help!


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

$(document).ready(main);


#2

Hi you should close the main function like that

var main = function() {
    $('.article').click(function() {
        ....
    });
    $(document).keypress(function(event) {
        ....
    });
}; # just with } and not with });

$(document).ready(main);

#3

Thanks! That worked!


#4

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