7. The o short cut (solved)


#1



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


There's pretty much only one error message:

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

Tried copying the code from the hint, which didn't work, neither did the suggestions offered in threads similar to mine.

Below is the code I'm using right now, the commented section is an attempt to include the unlisted text below the instruction points which tells you to add another keybind, however other people seem to have solved it without it.

Am I missing something really obvious?


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).keypress(function(event) {
     
 });
*/

}

$(document).ready(main);

#2

Hi I just ran you code and it work..


#3

For real? Just tried running it again, and copied it from the post into the editor again, still nothing.


#4

try to refesh the page or try it in another browser..


#5

...it just worked. I edited something in the .html before and after deleting that it worked. My bad, feel free to delete this topic.

edit: in case someone has this problem, the "reset code" button doesn't actually reset the whole .html code if you've left your changes in there for a while. You have to delete them manually to restore the original. Cheers


#6

can't delete it.. And it could help someone else..


#7

@digitalrockstar63332

the "reset code" button doesn't actually reset the whole .html code if you've left your changes in there for a while. You have to delete them manually to restore the original

That's because most of these exercises build on top of the previous lesson's code, so resetting the code on exercise #3 will only reset it to what was in #2, so if you messed something up in exercise #1, it will still have the mistake for example :slight_smile:


#8

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