The o shortcut


#1



Link to exercise


I know this exercise has been posted over and over again, I read the solutions posted but it is still not working.
I'm not sure what I am missing here...

Error messages:
* Uncaught SyntaxError: Unexpected token )

  • 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.


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

I had the exact same problem. I did exactly what the instructions said, but NOTHING worked! Please help!


#3

Okay, @neededausername and @melnyx.

So, this

should be current ('current') and not a current class ('.current'). You are already using the inbuilt function removeClass

I hope this helps! :slight_smile:


#4

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

try it . hope U can find the diffrent.


#5

This doesn't do anything. Can you send a screenshot of what the code should
look like?

Anna Rosner
Student, Sutherland Middle School

*"The Secret of change is to focus all of your energy, not on fighting the
old, but on building the new."*

-Socrates


#6

Also, here.

Your event should be in the function. You closed the function there. Remove the bracket closing the function immediately.

Cc: @melnyx

@neededausername , please post your own code.

Thank you. :slight_smile:


#7

Actually I did try changing it to ('current') before and wasn't working. However hackjane and you spotted the solution somewhere else:

Totally worked so, thanks a lot!!


#8

Thanks a lot!, after a good night sleep, I can see it now :smiley:


#10

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