jQuery Event How to - Handle double click event








Question

We would like to know how to handle double click event.

Answer


<!--  w w w .j av a  2s.  c  om-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
                $("div").bind("dblclick", function(e){
                  var str = "( " + e.pageX + ", " + e.pageY + " )";
                  console.log( str);
                });
        });
    </script>
    <style>
      div { width:50px; height:70px; float:left; margin:5px;
            background:rgb(255,140,0); cursor:pointer; }
     
    </style>
  </head>
  <body>
          <div>asdf</div>
  </body>
</html>

The code above is rendered as follows: