jQuery mousedown()Method

jQuery 事件方法jQuery Event Methods

Example

Press the left mouse button on a <div> element to insert some text:

$("div").mousedown(function(){ $(this).after("Mouse button pressed down."); });

Try it Yourself »

Definition and Usage

When the mouse pointer moves over an element and the left mouse button is pressed, the mousedown event occurs.

The mousedown() method triggers the mousedown event, or adds a function to run when a mousedown event occurs.

Tip:This method is usually used together with themouseup()method.


Syntax

Trigger the mousedown event of the selected element:

$(selector).mousedown() Try it Yourself

Add a function to the mousedown event:

$(selector).mousedown(function) Try it Yourself

Parameter Description
function Optional. Specifies the function to run when the mousedown event is triggered.


jQuery 事件方法jQuery Event Methods

Other Extensions