jQuery Event - mousedown() Method

Example

Hide or show the element when the mouse button is pressed:

$("button").mousedown(function(){
  $("p").slideToggle();
});

Try it yourself

Definition and Usage

The mousedown event occurs when the mouse pointer moves over an element and the mouse button is pressed.

Unlike the click event, the mousedown event only requires the key to be pressed, not released, to occur.

The mousedown() method triggers the mousedown event, or specifies the function to be executed when the mousedown event occurs.

Triggers the mousedown event

Syntax

$(selector).mousedown()

Try it yourself

Binds the function to the mousedown event

Syntax

$(selector).mousedown(function)
Parameters Description
function Optional. Specifies the function to be executed when the mousedown event occurs.

Try it yourself