jQuery mousedown() Method
The mousedown event occurs when the left mouse button is pressed down over the selected element.The mousedown() method triggers the mousedown event, or attaches a function to run when a mousedown event occurs.
Syntex:
$(selector).mousedown()
|
Note: This method is often used together with the mouseup() method.
Example :-
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div").mouseup(function(){
$(this).after("<p style='color:blue;'>Mouse button released.</p>");
});
$("div").mousedown(function(){
$(this).after("<p style='color:pink;'>Mouse button pressed down.</p>");
});
});
</script>
</head>
<body>
<div style="height:100px">click the mouse button near the text</div>
</body>
</html>
|