Do you guys see my coding is wrong?


#1

I keep getting this 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.

my code is,

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

Hi Jkjay,

Carefully monitor what you open, then where you close it. There are three places where you went wrong with your closing parenthesis ()) and closing curly braces (}):

  1. Line 7
  2. Line 14
  3. Line 15

You should move the closing curly brace on line 7 down to line 15, then line 14 needs a closing parenthesis after the closing curly brace (with the semi-colon (;) still at the very end of the line). :slightly_smiling:


#3

Thank you Zystvan,

I fixed as you advised,

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

I think curly brace in Line11 does not need semi-colon.
It still shows same error message.
Do you know what I miss or did something bad?

Thank you,


#4

@jkjay Lines 3 and 5 can't have the dot (.) between the removeClass() or addClass() parenthesis, and lines 4 and 6 can't have a second dot after something, but before it's parenthesis (if that makes sense):

// lines 3 & 5 example syntax
$('.class').addClass("pizza");
                   // ↑ no dot here 

// lines 4 & 6 example syntax
$('element').doSomething();
                     // ↑ no second dot here