English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The mousedown() method triggers a mousedown event, or attaches a function to be executed when a mousedown event occurs.
A mousedown event occurs when the user presses a mouse button on an element.
You might think that mousedown andclickThe event is the same, but they are not:
mousedown-Press the mouseleft or right button (or middle button) is triggered
click-Triggered only when the left mouse button is pressed and released on the same element
The mousedown() method is usually used withmouseup()Methods used together.
Trigger the mousedown event of the selected element:
$(selector).mousedown()
Attach a function to the mousedown event:
$(selector).mousedown(function)
Display text when the mousedown and mouseup events are triggered:
$("p").mousedown(function(){ $(this).after("<p style=\39;color:red;'>Press Mouse Button</p> }); $("p").mouseup(function(){ $(this).after("<p style=\39;color:green;'>Release Mouse Button</p> });Test See‹/›
Parameters | Description |
---|---|
function | Function executed when the mousedown event is triggered |