Why the 0 short cut does not work?


#1



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


#2

@bytemaster81548
You are placing the 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();
});

Do not forget to use
$(document).ready(main);

==========================================================

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

==================================================

Compilation of News Reader (2015-07-13)
http://www.codecademy.com/forum_questions/55a287509113cb33bd000839
Compilation of News Reader (2016-02-02)
http://discuss.codecademy.com/t/help-me-on-o-shortcut/25483/2?u=leonhard.wettengmx.n


#3

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