jQuery mouseup() Method
You are Here:
jQuery mouseup() Method
The jQuery mouseup()
method is used for the following 2 purpose
- To run a callback when a specified element is released after pressing.
- To trigger the mouseup event of a specified element.
Run a Callback
In the following example, we will run a callback function when a paragraph is released after pressing.
Example
HTML Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery mouseup() Method</h1>
<p>Press and release Me.</p>
<script>
$(document).ready(function(){
$("p").mouseup(function(){
alert("Paragraph is pressed and released.");
});
});
</script>
</body>
</html>
Syntax
$(selector).mouseup(callback);
Parameter Values
Value | Type | Explanation |
---|---|---|
callback | Optional | Specifies a function to be called once user mouse is press and released on the element. |
Trigger a mouseup Event
In the following example, we will trigger a mouseup event when a button is clicked.
Example
HTML Editor
!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery mouseup() Method</h1>
<p>Press and release Me.</p>
<button>Trigger mouseup Event</button>
<script>
$(document).ready(function(){
$("p").mouseup(function(){
alert("Paragraph is pressed and released.");
});
$("button").click(function(){
$("p").mouseup();
});
});
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in jQuery.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.