Interactive website- shortcut -o


#1

I have the following code but I still get an error asking me to try again. What could be wrong? I have checked the braces and parenthesis and they seem correct to me.



var main=function(){
    
    $(".article").click(function(){
       $(document).keypress(function(event) {
  if(event.which === 111) {
    $('.current').children('.description').toggle();
  }
});
        $('.article').removeClass('current');
        $(this).children("description").hide();
     
        $(this).addClass("current");
        $(this).children("description").show();
        })
    };   
    $(document).ready(main)


#2

You wrote the word, article, in the first click function in double quotes. This is what you have:

This is what you should have:

$('.article').click(function(){

Hope that helps and let me know if it works!


#3

Thank you pinky_1. I made the change and it still does not work. I have been using double quote but it was working just fine.


#4

I just checked the exercise and the instructions. The order of your code is wrong. It should be like this:

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

That should work. Let me know if it still does not work or if your problem is solved!


#5

Thank you! I've been struggling with this exercise for a while now. :slight_smile: I wish you could get the code for the older lessons too. The older ones seem to have a different design.


#6

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