Home >>jQuery Tutorial >jQuery mouseup() Method

jQuery mouseup() Method

jQuery mouseup() Method

jQuery mouseup() method in jQuery is used to add a function or triggers the mouseup event to run when a mouseup event occurs over the selected element.

Syntax:

Trigger the mouseup event for the selected elements:

$(selector).mouseup()

Attach a function to the mouseup event:

$(selector).mouseup(function)

Parameter Values

Parameter Description
function It is an optional parameter and is used to specifies the function to run when the mouseup event is triggered
Here is an Example of jQuery mouseup() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".txt").mouseup(function(){
$(this).after("<p style='color:orange;'>Mouse button released.</p>");
});
$(".txt").mousedown(function(){
$(this).after("<p style='color:lightgreen;'>Mouse button pressed down.</p>");
});
});
</script>
</head>
<body>
<div class="txt">You can press down and release the mouse button over me !</div>
</body>
</html>

Output:
You can press down and release the mouse button over me !