Problems with O shortcut


#1

Having trouble with the O shortcut even though I don't see a problem with it!

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

Syntax: Missing ) after argument list

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

#2

We can see at least three problems...

Add what class?

Remove what class?

document is not a class, but the document root object.

The above line appears twice.

There may be a problem with the ordering, as well. Are we not given the instructions in the order in which the code would logically be written?

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

#3

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