O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling the Mouse Entering or Leaving Elements

$("p").on("mouseover", function (e){   $(this).html("Hello mouse."); }); $("p").on("mouseout", function (e){   $(this).html("Wait, don't go."); });

The browser provides an event each time the mouse enters or leaves an element. The standard JavaScript events are mouseover and mouseout, so you can use .on("mouseover") to add an event handler for the mouse entering an element and .on("mouseout") to add an event handler for when the mouse leaves.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required