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+).
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("#target").on("mousedown", function () { ... })
$("#target").trigger("mousedown")
// Fires on press (any button)
// Prefer on/trigger — not the deprecated .mousedown()
// Left button: event.which === 1
Call
What it does
mousedown
Learn the jQuery mousedown event: bind with .on(\
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the element(s): $("#box"), $("p"), etc.
Step 2
Bind: .on("mousedown", function (event) { ... }).
Step 3
Optional: gate on event.which === 1 for the left button.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
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.");
});
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");
});
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.