Hover problem


#1

this is my code

$(document).ready(function(){

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

});

i think there is no problem but it showing error ...


#2

Hey @arunshukla111,

What error is it giving you? I will try my best to help you... Can you also add a link to the exercise in question?


#3

I am having the exact same problem. The error that I get is "Oops, try again. Unable to get property '1' of undefined or null reference". I am on this exercise: https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/2?curriculum_id=50a3fad8c7a770b5fd0007a1.
Here is my code:

$(document).ready(function(){

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

I don't want to know the answer, I just want to know why my code is wrong.


#4

There is no problem with your code. when you click "save and submit code", then first hover on "HOME",then on "About US" and then on "Contact". you will get no error message.


#5

Hover each div for at least 2 seconds.


#6

Thank you so much. It worked for me!!! :slight_smile:


#7

This topic was automatically closed after 2 days. New replies are no longer allowed.