Example 1 — Bind with .mouseout(handler)
Log leave events with the deprecated binding shorthand — child crossings also fire.
$("#outer").mouseout(function () {
$("#log").append("Handler for mouseout called.\n");
});
// Prefer: $("#outer").on("mouseout", function () { … }); How It Works
- Pass a function.
.mouseout(fn)registers the handler (deprecated). - Leave the element. Exiting to the page runs the function.
- Cross into a child. Outer → Inner also fires because mouseout bubbles.
- Migrate. Swap to
.on("mouseout", fn)— ormouseleavefor nesting.

