jQuery mousedown Event

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is the mousedown Event?

mousedown is sent when the mouse button is pressed while the pointer is over an element — before release. Bind it with .on("mousedown", handler) (jQuery 1.7+).

Remember
$("#target").on("mousedown", function () { ... })
$("#target").trigger("mousedown")

// Fires on press (any button)
// Prefer on/trigger — not the deprecated .mousedown()
// Left button: event.which === 1
NeedUse
Bind handler.on("mousedown", handler)
Fire event.trigger("mousedown")
Which button?event.which (1 / 2 / 3)
Press + releaseclick

How to Use mousedown

Select an element, bind with .on, optionally check event.which.

  1. Select the element(s): $("#box"), $("p"), etc.
  2. Bind: .on("mousedown", function (event) { ... }).
  3. Optional: gate on event.which === 1 for the left button.
  4. To fire in code: .trigger("mousedown"). Unbind with .off("mousedown").
PieceRequired?Role
"mousedown"YesEvent type string for .on / .trigger
handlerYes (bind)Runs on each button press
eventDataOptionalExtra data passed into the handler
Return value—jQuery set (chainable)

Pseudocode

Pseudocode
function onMousedown(element, handler):
    when pointer is over element
     and any mouse button is pressed:
        handler(event)   // event.which = 1|2|3

trigger(element, "mousedown"):
    run all mousedown handlers on element

Cheat Sheet

Keep these facts handy while wiring press handlers.

TopicDetail
Bind.on("mousedown", handler) (1.7+)
Trigger.trigger("mousedown") (1.0+)
WhenButton pressed over the element
event.which1 left · 2 middle · 3 right
vs clickPress only — no release required
Unbind.off("mousedown")
Deprecated.mousedown() shorthand (3.3+)

Live Preview

Run presets that use .on("mousedown") and .trigger("mousedown").

Uses .on("mousedown") and .trigger("mousedown") — same ideas as the examples below.

Result
Handler for mousedown called.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Bind a mousedown Handler

Official style: .on("mousedown", …) on a target element.

jQuery
$("#target").on("mousedown", function () {
  console.log("Handler for mousedown called.");
});
Try It Yourself

How It Works

  1. Select #target.
  2. Bind with .on("mousedown", handler).
  3. User presses a mouse button over the element.
  4. Handler runs immediately — no release needed.

Example 2 — Trigger mousedown from Code

Fire the same handlers with a single click on another control.

jQuery
$("#target").on("mousedown", function () {
  console.log("Handler for mousedown called.");
});

$("#other").on("click", function () {
  $("#target").trigger("mousedown");
});
Try It Yourself

How It Works

  1. Bind the real handler on #target.
  2. Another control listens for its own click.
  3. trigger("mousedown") runs #target’s handlers.
  4. Same message as pressing on #target.

Example 3 — Left Button Only (event.which)

Official tip: start drag-like actions only on the primary button.

jQuery
$("#box").on("mousedown", function (event) {
  if (event.which !== 1) {
    return; // ignore middle / right
  }
  console.log("Primary button pressed");
});
Try It Yourself

How It Works

  1. which is normalized by jQuery: 1 / 2 / 3.
  2. Return early if it is not the left button.
  3. Right-click menus stay usable.
  4. For menus, prefer contextmenu over which === 3.

Example 4 — Pair with mouseup

Official demo idea: log both press and release on the same element.

jQuery
$("p")
  .on("mousedown", function () {
    $(this).append(" Mouse down.");
  })
  .on("mouseup", function () {
    $(this).append(" Mouse up.");
  });
Try It Yourself

How It Works

  1. mousedown appends text on press.
  2. mouseup appends text on release.
  3. Order is always down then up for a normal press.
  4. Chain both with .on on the same set.

Example 5 — Event Delegation

One parent handler covers current and future children.

jQuery
$("#list").on("mousedown", "li", function () {
  console.log("Press: " + $(this).text());
});

// Later…
$("#list").append("<li>New item</li>");
// New item works too — no extra bind
Try It Yourself

How It Works

  1. Bind on parent #list, filter with "li".
  2. Press bubbles from the li to the list.
  3. this is the matched li.
  4. New items work automatically after append.

Edge Cases & Pitfalls

Watch these when relying on mousedown handlers.

deprecated

Avoid .mousedown() shorthand

Deprecated in 3.3. Use .on("mousedown") / .trigger("mousedown") / .off("mousedown").

vs click

Press-away cancels click, not mousedown

Press inside then release outside still counts as mousedown. Prefer click for finished actions.

which

Gate drags on which === 1

Ignoring middle/right presses avoids fighting with scroll-click and context menus.

right

Right-click is unreliable via which

Some browsers do not expose right button mousedown clearly. Use contextmenu for menus.

dynamic

New DOM nodes need delegation

Prefer .on("mousedown", "child", fn) on a stable parent for lists and boards.

Browser Support

The native mousedown event works in all browsers. Bind with .on("mousedown") since jQuery 1.7; .trigger("mousedown") since 1.0. Prefer these over the deprecated .mousedown() shorthand (3.3+).

✓ jQuery 1.7+ (.on)

mousedown event

Supported everywhere jQuery event APIs run in the browser. Use on/trigger for modern code.

100% Browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
on("mousedown") Excellent

Bottom line: Bind with .on("mousedown", fn). Check event.which for the primary button. Prefer click when you need a full press-and-release.

Performance Notes

ApproachCostBest for
Direct .on("mousedown")1 handler / elementFew static controls
Delegated .on1 handler / parentLists / canvases / dynamic UI
Heavy work on every pressCan feel laggyKeep handlers light; defer work

Delegation scales better than binding hundreds of individual press handlers. Always .off when removing long-lived widgets to avoid leaks.

Key Takeaways

  • Bind: .on("mousedown", handler) — not deprecated .mousedown().
  • Timing: fires on press — before release.
  • Buttons: use event.which (1 left / 2 middle / 3 right).
  • Prefer click for finished actions; mousedown for press / drag-start.

One line: use .on("mousedown", fn) for immediate press handling — check event.which when the button matters.

Frequently Asked Questions

mousedown fires when the mouse button is pressed while the pointer is over an element — before release. Bind with .on("mousedown", handler) (jQuery 1.7+). Any HTML element can receive it.
Prefer .on("mousedown", handler). The .mousedown(handler) shorthand is deprecated since jQuery 3.3. To fire the event, use .trigger("mousedown") instead of .mousedown().
mousedown fires on press. click needs press and release inside the same element. If the user presses inside then releases outside, mousedown still fired but click does not.
jQuery normalizes event.which: 1 = left, 2 = middle, 3 = right. Use which === 1 to start drags only on the primary button so right-click context menus are not disrupted.
Call $(selector).trigger("mousedown"). That runs bound handlers. Use .triggerHandler("mousedown") to run handlers without default browser behavior.
event.which === 3 means right button, but it is not fully reliable in every browser. Prefer the contextmenu event for custom right-click menus.

Next: .mousedown() shorthand

See the deprecated helper and how it maps to on / trigger.

.mousedown() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful