O isn't opening a description, I can't see what I could be missing


#1



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


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.


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


#2

@smolderingflax,
You pasted-in your document =keypress= Eventhandler

         $(document).keypress(function(event) {
          if(event.which === 111) {
            $('.current').children('.description').toggle();
              }
            });

into the middle of your article =click= Eventhandler

$('.article').click(function(){
      $('.article').removeClass('current'); 
      $(".description").hide();
      $(this).addClass("current");
      $(this).children(".description").show();
        
      });

and do not forget to use
$(document).ready(main);
to activate the
main` function.

the structure of our _main_-**function** looks like:

    var main = function() {
         //BEGIN of main function-body 
        //
        //The CLICK event-handler is

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

         });
    
         //now comes the KEYPRESS event-handler

         $(document).keypress(function(event) {

           });
       //END of main function-body
       };
    
      $(document).ready(main);

#3

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