The o shortcut, o key not responding


#1

Alright folks,

please save me the agony of another hour of re-setting this code!
"oops the o key isn't opening the description...."

I have looked at problems other have had, to no avail.

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

$(document).ready(main);

thanks!


#2

Hi your code should have that structure

var main = function() {
    $('.article').click(function(){#open the click function
        ...
    });#close the click function
    
    $(document).keypress(function(event){#open the keypress
        ...
    });#close the keypress
};

$(document).ready(main);

#6

Thanks wizmarco......implemented those, to no avail. Still not getting the o key to give me the desired result. new 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();
  
});
}

$(document).ready(main);

#7

why click function block is empty?


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

#9

thank you so very much! :slight_smile:


#10

it's ok brother! Happy coding and help another coder.:slight_smile:


#11

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