Overview
Bind a handler function to the mousedown event of each matching element.
The mousedown event will be triggered after the mouse clicks on the element
Parameters
fnFunctionV1.0
Bind in the mousedown event of each matching element processing function.
[data],fnString,FunctionV1.4.3
data:mousedown([Data], fn) data can be passed in for function fn to process.
fn: The handler function bound in the mousedown event of each matching element.
Example
Description:
Hide or show an element when the mouse button is pressed:
jQuery Code:
$("button").mousedown(function(){ $("p").slideToggle(); });
Example 1
Hide or show elements when the mouse button is pressed:
##
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").mousedown(function(){ $("p").slideToggle(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button>切换</button> </body> </html>
<span style="font-weight: normal;"><span style="font-weight: normal;"><html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").mousedown(function(){ $("p").slideToggle(); }); $("#mousePara").mouseover(function(){ $("button").mousedown(); }); }); </script> </head> <body> <p> <p>这是一个段落。</p> <p>这是另一个段落。</p> </p> <button>切换</button> <p id="mousePara">如果您把鼠标移动本段落上,会激活上面这个按钮的 mousedown 事件。</p> </body> </html></span><span style="font-weight: 400;"> </span></span>
function to be run when the mousedown event occurs.
$(selector).mousedown(function)
Description | |
---|---|
Optional. Specifies a function to run when a mousedown event occurs. |
The above is the detailed content of jQuery: usage and definition of mousedown event. For more information, please follow other related articles on the PHP Chinese website!