.hover() binds handlers for mouseenter and mouseleave in one call. With two functions it runs enter then leave; with one function (since 1.4) the same handler runs for both. Prefer .on in new code.
One handler (legacy, 1.4+): .hover(fn) — check event.type if needed.
Unbind with .off("mouseenter mouseleave").
Piece
Required?
Role
handlerIn
Two-arg form
Runs on mouseenter
handlerOut
Two-arg form
Runs on mouseleave
handlerInOut
One-arg form
Runs on enter and leave
Return value
—
jQuery set (chainable)
Pseudocode
Pseudocode
function hover(element, fnIn, fnOut?):
if fnOut given:
on mouseenter → fnIn
on mouseleave → fnOut
else:
on mouseenter → fnIn
on mouseleave → fnIn // same function
// Prefer naming events with .on("mouseenter") / .on("mouseleave")
Reference
Cheat Sheet
Quick map from shorthand to modern calls.
Legacy
Modern
.hover(fnIn, fnOut)
.on("mouseenter", fnIn).on("mouseleave", fnOut)
.hover(fn)
.on("mouseenter mouseleave", fn)
Unbind
.off("mouseenter mouseleave")
Added
1.0 (one-arg form 1.4)
Status
Deprecated 3.3+
Try it
Live Preview
Run presets that show two-handler hover, single-handler, unbind, and migration (simulated with mouseenter / mouseleave triggers).
Legacy demos for reading old code — prefer .on("mouseenter") / .on("mouseleave") in new projects.
Result
enter
leave
Code
jQuery Examples
Short snippets for legacy .hover(). Prefer the modern forms in new work — use Try It Yourself to experiment.
Example 1 — .hover(fnIn, fnOut)
Official style: enter appends a marker; leave removes it.
jQuery
$("li").hover(
function () {
$(this).append(" ***");
},
function () {
$(this).text($(this).text().replace(" ***", ""));
}
);
.hover(fnIn, fnOut) is a thin wrapper around two .on calls.
.on is not deprecated and supports delegation.
New projects should only use .on / .off.
Edge Cases & Pitfalls
Common traps when reading or writing .hover() code.
deprecated
Do not use in new code
Both signatures are deprecated since 3.3. Teach and write .on("mouseenter") / .on("mouseleave").
unbind
No "hover" event name
Clean up with .off("mouseenter mouseleave"), not .off("hover").
vs over
Not the same as mouseover
mouseover/mouseout bubble through children. Enter/leave usually match “hover this box” better.
css
Prefer CSS for pure style
Colors and simple highlights belong in :hover. Use JS when you need DOM or logic changes.
touch
Limited on touch devices
There is no true hover on many phones. Don’t rely on hover-only UI for critical actions.
Compatibility
Browser Support
.hover() has existed since jQuery 1.0 (one-arg form since 1.4). It still runs in jQuery 3.x browsers, but is deprecated since 3.3 — prefer .on("mouseenter") / .on("mouseleave").
✓ Deprecated 3.3+
.hover() shorthand
Works wherever jQuery event APIs work in the browser. Use on/off for new code.
Switching to .on does not slow you down — it clarifies intent and unlocks delegation. Keep enter/leave handlers light.
Remember
Key Takeaways
Deprecated:.hover() since jQuery 3.3.
Meaning: shorthand for mouseenter + mouseleave.
Modern:.on("mouseenter", …).on("mouseleave", …).
Unbind:.off("mouseenter mouseleave") — not "hover".
One line:.hover() is a deprecated enter/leave shorthand — prefer .on("mouseenter") and .on("mouseleave").
Frequently Asked Questions
With two functions — .hover(handlerIn, handlerOut) — it binds mouseenter and mouseleave. With one function since 1.4 — .hover(handlerInOut) — the same function runs for both events. Both forms are deprecated since jQuery 3.3.
Yes. Prefer .on("mouseenter", handlerIn).on("mouseleave", handlerOut) for two handlers, or .on("mouseenter mouseleave", handlerInOut) for one. jQuery 3.x still runs .hover() for compatibility.
CSS :hover is stylesheet-only. .hover() runs JavaScript on enter/leave — useful for DOM changes and logic CSS cannot express. Prefer CSS for pure styling.
.hover() uses mouseenter/mouseleave, which do not re-fire when moving over child elements. mouseover bubbles and re-fires on child boundaries — often noisier for menus and highlights.
Use .off("mouseenter mouseleave") on the same elements. There is no separate "hover" event name — .hover() registers under mouseenter and mouseleave.
Replace .hover(fnIn, fnOut) with .on("mouseenter", fnIn).on("mouseleave", fnOut). Replace .hover(fn) with .on("mouseenter mouseleave", fn).