Combine jQuery click And dblclick Events With oneOrDoubleclick Plugin

File Size: 7.28 KB
Views Total: 406
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Combine jQuery click And dblclick Events With oneOrDoubleclick Plugin

oneOrDoubleclick is a jQuery plugin to replace the jQuery click and dblclick events that trigger appropriate functions when an element is clicked or double clicked.

How to use it:

1. Download and place the minified version of the jQuery oneOrDoubleclick plugin after jQuery library.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" 
        integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" 
        crossorigin="anonymous">
</script>
<script src="dist/jquery-oneordoubleclick.min.js"></script>

2. Call the function on the target element and execute your own functions when the element is clicked or double clicked.

<div class="demo">
  Click & Dbclick Me
</div>
$(function(){

  $('.demo').oneordoubleclick({oneclick: function(){
    alert('you have clicked this node.');
  }, dblclick: function() {
    alert('you have double clicked this node.');
  }
  });

});

3. Set the interval of a click. Default: 400ms.

$('.demo').oneordoubleclick({
  interval: 500,
  oneclick: function(){
  alert('you have click this node.');
}, dblclick: function() {
  alert('you have double click this node.');
}
});

This awesome jQuery plugin is developed by sgyyz. For more Advanced Usages, please check the demo page or visit the official website.