I like it, but it seems kinda glitchy


#1

My code works in my own editor, when I paste it in the codecademy editor I can see in the preview it's doing what it's supposed to. But I'm still getting an error message. I have been through the treehouse courses and I need a break from them. I like this format, except...the bugginess. This same thing has happened several times tonight.


#2

Hey,

Please provide more information: what course/lesson (paste in URL), what error you getting and paste in your code


#3

var main = function(){
  // click article to initiate the code
  $(".article").click(function(){
    // set the letter o as a shortcut
    $(document).keypress(function(event){
      if(event.which === 111){
        // current is the headline we click on
        // description is the paragraph that pops out under
        $(".current").children(".description").toggle();
      }
    });
    $(this).siblings(".article").removeClass("current");
  // hide all descriptions
    $(".description").hide();
    // add grey to the clicked on element
    $(this).addClass("current");
  // this=.article children that have the class description will be shown
    $(this).children(".description").show();
  });
}

$(document).ready(main);

this code runs fine in my own editor with no errors
https://www.codecademy.com/en/courses/web-beginner-en-4hxyb/0/7?content_from=make-an-interactive-website%3Ajquery-events
I get this error from the codecademy editor
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.


#4

@smolderingflax First, you need to move the $(document).keypress(...); part outside of the $(".article").click(...); part.

Then, rather than $(this).siblings(...)... to remove the class, why don't you just use $('.article').removeClass("current");?


#5

Inside the main() function under your click event handler, create a keypress event handler:
In that case the above line of instruction is ambiguous. It could be taken either way. Inside the main function ABOVE the click handler would be clearer. And Thank you for your concise and helpful reply. Although, that being the case, this should not have passed me to the next section. But it did. Buggy.


#6

Buggy

There's nothing we can do to fix the course right now, since Codecademy is planning on removing it sometime this year I've been told.

Sorry, it annoys me too :confused:


#7

Are they updating it or quitting?


#8

Removing this course, adding in extra bits to the jQuery and JavaScript courses as they update those. I don't know how similar any of the content in the updated courses will be to this one, though.


#9

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