mouseup() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:mouseup

Description

The mouseup() method triggers the mouseup event, or sets function as mouseup event handler.

Syntax

$(selector).mouseup(function);
Parameter Require Description
function Optional. function to run when the mouseup event is triggered

The following code shows how to Release the left mouse button over a <div> element to insert some text:

Demo Code

ResultView the demo in separate window

<!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:green;'>Mouse button released.</p>");
    });/*from   w ww . j  a va  2 s.  c  o m*/
    $("div").mousedown(function(){
        $(this).after("<p style='color:purple;'>Mouse button pressed down.</p>");
    });
});
</script>
</head>
<body>

<div>Press down and release the mouse button here.</div>

</body>
</html>

Related Tutorials