I don't understand what's wrong with my code


#1

I can't find out what's wrong with my code either

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

Can someone please explain what's wrong here?


O shortcut || What is wrong with my code?
#2

Hi Ramon,

Please post a link to the exercise you're on and the error message you're getting so we can help you.


#3

Hi zystvan

this is the link:
https://www.codecademy.com/courses/web-beginner-en-4hxyb/0/7?content_from=make-an-interactive-website%3Ajquery-events

and the error code:
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.

Thanks for your support


#4

Hi did you have that part at the bottom of yout code?

$(document).ready(main);

#5

No i haven't, it did the trick.

Thanks a lot


#6

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