Introduction:

In this article we will explain how to use mouseup() method in jquery or  how to attach mouse up event to a html element.

Description:

jQuery mouseup() method attach an event handler function to an HTML element. This function is executed, when the left mouse button is released after pressing mouse button on the HTML element.

The mouseup () event occurs when you release the pressed button of your mouse over a selected element. Once the mouseup() event is occurred it executes the mouseup() method attached with a function to run.

syntax:

$(selector).mouseup(function)

jQuery mouseup() example

Let's take an example to see the mouseup() event in jQuery. In this example, when the left mouse button is released after pressing mouse button on the “h1” element then “h2” text will be written inside it.

 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Jquery Tutorials</title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script>       
            $(document).ready(function () {
                $("#h1").mouseup(function(){   
                    $("h2").text("mouse up event triggered");
                });
            });
    </script>  
</head>
<body>
    <h1 id="h1">Click here your Left mouse button.</h1>
    <h2></h2>       
</body>
</html>

Output:

How to attach mouse up event to a html element in jQuery

I hope it will help to you after reading it.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like