Need help with this code


#1

$(document).keypress(function(event) {

$('.current').children('description').toggle();
}
});
{(document).ready(main);
having issues with this code i do not know what to do
please help


O shortcut :(
#2

Hi Micheliewelly,

Could you please post a link to the exercise you're on?
Thanks :slightly_smiling:


#3

Hi Zystvan

Unfortunately i'm not the person who's supposed to post the link, but i have exactly the same problem as Micheliewelly so i'll post my link. https://www.codecademy.com/en/courses/web-beginner-en-4hxyb/0/7?content_from=make-an-interactive-website%3Ajquery-events

Thanks


#4

@fiksatuwc That's fine :slightly_smiling:
Is your code exactly the same as @micheliewelly's? If it's different, would you mind posting your code as well please?

Thanks :slightly_smiling:


#5

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


#6

@fiksafuwc

Problem one is right here:

This post explains why you can't have the dot (.) inside addClass():

Then, on what I think is line 8 in your code, this:

That only closes the function() {...}; part, not the $('.article').click(...); piece as well. You need to add a closing parenthesis ()) after the closing curly brace (}) so that line 8 looks like this:

});

#7

A post was split to a new topic: What's wrong here?