Lessons 6 and 7 accepting incomplete code


#1

First off, I love this site and really appreciate having the opportunity to work with scripting in such a great environment.

Just FYI, I did lessons 6-7 incorrectly at first but it still said 'Way to go' and moved me along. Originally, I had this for lesson 6:

$(document).ready(function(){
    $('#text').addClass('highlighted');
});

This adds the class automatically (without clicking). The same code worked on the toggling section. I realized what I had done and changed it to include the nested function, but just wanted to post this since it could cause some confusion for folks. Not sure if this qualifies as a bug or not, but I'll go ahead and tag it that way just in case.

Thanks again for the great course!

Matt


#4

Similarly, My code is "correct" but the .toggleClass() function isn't working in the output window.

And Matt, good on ya for giving props and criticism where its needed.


#5

Hi giganinja!
Not sure if you're still having trouble with the code or not, but I can tell you what helped me out with this one. There's actually some text in the beginning of the next section of the course that was useful here:

"The setup almost always looks like this:

   $(document).ready(function() {
       $('thingToTouch').event(function() {
           $('thingToAffect').effect();
       });
   });

where "thing to touch" is the HTML element you'll click on, hover over, or otherwise interact with, and "thing to affect" is the HTML element that fades away, changes size, or undergoes some other transformation."

I realized that I was missing the "thing to touch" part. That is, I needed to add a function so that something would happen when an element with the #Text ID was clicked. Then I needed to add a separate (nested) function within that so that the toggling would happen (that's the "thing to affect" part from the sample above).

Hope this helps!

Matt


#6

I did this code as well which gave me a pass but I always check the hints section to see if my code is similar before I proceed to the next lesson. I was horrified when I saw that my code was completely different but I understood why and changed it accordingly.


#7

Matt, thanks for confirming, I did the same error but I was told "Way to go"! Hope Codecademy fixes it.