Jquery exercise remove();


#1

It seems to work right in the “test” window, but I am not able to continue with the exercises and I am not able to spot the error myself. I get this error “Oops, try again. It does’t look like your background color changed, is your hover adding the class active?”, anyone who can help please :)?

$(document).ready(function(){

 $('div').hover(
    function(){
      $(this).addClass('active');
   },
   function(){
      $(this).removeClass('active');
   }
);

});

#2

Can you include the exercise url so we can run the code in the exercise?


#3

https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/2?curriculum_id=50a3fad8c7a770b5fd0007a1#


#4

Did you get it :)? I have posted the URL here


#5

yes, i did. Uhm… the course you take is no longer supported, as such, it might be bugged, you can try mouseenter and mouseleave:


$(document).ready(function(){
    $('div').mouseenter(function(){
        $(this).addClass('active');
    });
    $('div').mouseleave(function(){
        $(this).removeClass('active')
    })
});

that might work slightly better, make sure to enter with your mouse (in full screen output window after submitting), wait a few seconds before moving the mouse outside the div


#6

It worked! Thank you! :slight_smile: mouseenter does the same as mouse hover? I guess?


#7

I would still recommend updating the a supported version of a course

Well, they are similair but not the same.


#8

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