Interactive website part 7


#1

var main = function() {
$('.article').click(function() {
    $(document).keypress(function(event) {
        if(event.which === 111){
        $('.current').children('.description').toggle();
    }
    });
        
    $('.description').hide();
    $('.article').removeClass('current');
    $(this).children('.description').show();
    $(this).addClass('current');
});
};
$(document) .ready(main);

What's wrong with my code?


#2

Hi Deesilby,

The

$('.article').click(function() {
  // ...
});

bit and the

$(document).keypress(function() {
  // ...
});

bit need to stay separate, not inside each other.


#3

Thank you so much! I made the same mistake and I was raking my brain and couldn't figure it out. :slightly_smiling: