Need your helps to solve the problem 7


#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').toggleClass();

        }
    });
});

};

$(document).ready(main);

I thought there were no errors, but they said that I '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 am struggling to understand why I got the error....


#2

Hi Sung2468,

You need to be toggling a specific class there. Do you know what it is?

Hint

The class name is current, so:

/* ... */.toggleClass('current');


#3

@sung2468,

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

#4

No. I don't..

I just followed to put by your answer, but it did not work out..


#5

@sung2468,

google search
== the Book ==
jquery [your question] site:developer.mozilla.org
CSS [your question] site:developer.mozilla.org
javascript [your question] site:developer.mozilla.org
[your question] site:jquery.com
[your question] site:getbootstrap.com

== discussions / opinions ==
jquery [your question] site:stackoverflow.com
CSS [your question] site:stackoverflow.com
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
[your question] site:crockford.com
- - http://javascript.crockford.com/code.html
- - http://javascript.crockford.com/survey.html

http://stackoverflow.com/questions/1795438/load-and-execution-sequence-of-a-web-page
http://www.w3schools.com/jquery/trysel.asp


#6

sung2648,
Please,seperate the the two events click event and keypress event like this and you will get a solution, I was stuck up with this exercise for two days,hope this helps:

var main= function() {
$('.article').click(function() {


   ----------
   -----------  your code for click event

}
); 

$(document).keypress(function(event){
 if(event.which === 111) {
     ----------
    ----------
    ----------- code for keypress event
 }
});

};

$(document).ready(main);