7/10 The O Shortcut


#1

Have been looking at differnt solutions for this and can't seem to figure out my error. Codeacademy returns the error " It looks like the o key isn't opening a description......". Here is my code, please can anyone help.

var main =function(){
    $('.article').click(function(){
// Select all other articles using the 'article' class and remove the class 'current' from them using .removeClass(). 
        $('.article').removeClass('current');
        $('description').hide();
// Select the current article using this. Add the class 'current' to it using .addClass().
        $(this).addClass('current');
        $(this).children('.description').show();
    }); // end click function

// Create a keypress event handler
    $(document).keypress(function(event){
    if (event.which === 111){
        $('current').children('.description').toggle();
    } //end if
    }); // end keypress function
}; //end main
$(document).ready(main);

#3

A post was split to a new topic: 7/10 The O shortcut, can't pass exercise


#4

Hi Andrew,

Can you see the problem there?

Hint

You need a dot (.) right in front of description, but still inside the single quotes (' ') and parenthesis (()), like this:

$('.description') //...


#5

Thanks so much for for the assistance. These dots are tricky. I added one to* $('.description').hide();* and to
$('.current').children('.description').toggle();. It now lets me pass the exercise and I can use the o key o toggle an article into and out of view.


#6

@scriptpro91844 My bad, I missed something else. You've got the same problem with $('current'); it needs a dot (.) right in front of current, and then I think your code should work :)


#7

A post was split to a new topic: Exercise 7, the O shortcut - can't pass exercise


#8

thankx guys I was stuck at same .....


#9

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