6. Why are we adding opposite effects to the same handler?

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>
So on exercise 6, “jQuery events, Hover”, we add the exact opposite effects to the div (addClass and removeClass) within the same event handler (hover). How does this work? Surely if you hover, it would apply one of the effects, not both?

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Link to exercise: https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/2?curriculum_id=50a3fad8c7a770b5fd0007a1#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

``` Exercise example :

('div').hover( function(){ (this).addClass(‘highlight’);
},
function(){
$(this).removeClass(‘highlight’);
}
);

<do not remove the three backticks above>

no, the .hover is smart, it will see that there are two functions to this event, it will execute the first function for mouseenter and execute the second function on mouseleave

1 Like

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