How to attach Double click Event to Button using JQuery

Posted By  RRaveen On 14 Jan 2011 22:01:04
emailbookmarkadd commentsprint
No of Views:906
Bookmarked:0 times
Votes:0 times

Introduction

In this code snippet, I will show , how to attach double click event to button control using JQuery, sometimes you may need to use the double click event for specific action in web page. So this tips help to you to attach the event.

Implementation

As usual create a web project, create page and add JQuery library into page as like below,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DoubleClkDemo.aspx.cs" Inherits="DoubleClkDemo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to Attach double click event to button using JQuery</title>

    <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">  
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button id="btnsave" value="Save">
            Save
        </button>
    </div>
    </form>
</body>
</html>

Then write code to attach double click event to button using below code,

<script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#btnsave").dblclick(function() {
                alert("You have clicked two times" + $(this).text());
            });
        });
    
    </script>

That's all, now run and  click button two times, the output like below,

Image Loading

hopes help and thank you for reading.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top