7. The O shortcut


#1

Hi everyone! You all are so helpful. I enter this code but everytime I try to fix it it comes out wrong.

var main = function() {
$('article').click(function(); {
$('.article').removeClass('current');
$('.description').hide();

    $(this).addClass('current');
    $(this).children().show();
});

};
$(document).keypress(function(event) {
if(event.which === 111) {
$('.current').children('description').toggle();
}
});
$(document).ready(main);

any help would be great


#2

The selector given to the children() method should be a class...

$('.current').children('.description').toggle();

#3

While I did address the typo, my code did not work


#4

There is a stray semi-colon between ) and { that does not belong, ever.


#5

should be,

$(this).children('.description').show();

#6

That was helpful again but unfortunately it still says that the o key isn't operating. I greatly appreciate the help btw


#7

Once all the repairs are made, you will have something like this, which passes:

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

#8

Well i think it's because your $(document) is not inside your main function


#9

Thank you for this, before I checked this I had no idea what to do, awesome support :smile: