Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

mouseleave vs mouseout ?

I saw there is another method "mouseout" which seems to be similar to "mouseleave". I have tried to replace the "mouseleave" by "mouseout" and the result was the same. So what is the difference between them?

1 Answer

Here's a decent explanation in the MDN documentation.

"The mouseleave event is fired when a pointing device (usually a mouse) is moved off the element that has the listener attached.

Similar to mouseout, it differs in that it doesn't bubble and that it isn't sent until the pointer has moved from its physical space and the one of all its descendants."

https://developer.mozilla.org/en-US/docs/Web/Events/mouseleave