The o function


#1

Good day all

I have read most of the comment regarding this topic and this is my code. When I click on the article and press o it open and closes, but when I submit it keeps saying 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.

I have read and tried and moved this code around so much that I'm even confused now as to where it needs to go. Please can someone assist with a screenshot of the coding and in which line does what go. I only have so much time a day to do this and I have been stuck on this for a while now.

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

Thank you so much.
Charlene


#2

I came right.

I just moved the whole thing write to the bottom before the last line and it works. no more errors. See below the code i used?

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