jQuery mouseup()

Introduction

Release the left mouse button over a <div> element to insert some text:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from  w w  w.  j  a v a2  s .com
<script>
$(document).ready(function(){
  $("div").mouseup(function(){
    $(this).after("<p style='color:green;'>Mouse button released.</p>");
  });
  $("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 over this div element.</div>

</body>
</html>

The mouseup event occurs when the left mouse button is released over the selected element.

The mouseup() method triggers the mouseup event.

The mouseup() method can also run a function when a mouseup event occurs.

Trigger the mouseup event for the selected elements:

$(selector).mouseup()

Attach a function to the mouseup event:

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



PreviousNext

Related