How To Use Mouse Up Event Method In JQuery With Example

admin_img Posted By Bajarangi soft , Posted On 12-10-2020

In jquery we can get alert message on mouse up on h2 element so today we discuss how to get alert message in jquery

How To Use Mouse Up Event Method In JQuery With Example

The mouseup() method attaches an event handler function to an HTML element and the function is executed, when the left, middle or right mouse button is released, while the mouse is over the HTML element:
 

Step 1:Create index.html file and implement below code.

<h2 id="h2">Am h2 Mouse up on me</h2>


Step 2:Implement jquery to use Mouse up event method 

<script>
    $(document).ready(function(){
        $("#h2").mouseup(function(){
            alert("Mouse up over p1!");
        });
    });
</script>


Complete Code For Mouse Up Event Methods With JQuery

<!DOCTYPE html>
<html>
<head>
    <title>How To Use Mouse Up Event Method In JQuery With Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<style>
    body {
        background: darkolivegreen;
    }
</style>
<body>
<div class="container">
    <br>
    <br>
    <br>
    <div class="text-center">
        <h2 id="color" style="color: White"> Mouse Up Event Method With JQuery</h2>
    </div>
    <br>
    <br>
    <div class="well">
        <h2 id="h2">Am h2 Mouse up on me</h2>
    </div>
</div>
</body>
</html>
<script>
    $(document).ready(function(){
        $("#h2").mouseup(function(){
            alert("Mouse up over p1!");
        });
    });
</script>

Related Post