Handling Multi-click Events In jQuery - mclick.js
File Size: | 2.37 KB |
---|---|
Views Total: | 136 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
mclick.js is a simple jQuery plugin that enhances your website's interactivity by detecting and responding to multiple consecutive click/tap events on specific elements.
In addition, the plugin ensures that only intended interactions are recognized by setting a timeout period to ignore click events that occur with intervals beyond the specified duration.
How to use it:
1. To get started, load the mclick.js script after jQuery library.
<script src="/path/to/cdn/jquery.slim.min.js"></script> <script src="/path/to/mclick.js"></script>
2. Select the element you want to detect multiple clicks on and call the mclick() method:
<div id="example"> ... </div>
$(function(){ $('#example').mClick() });
3. This will trigger a callback function after three clicks within 800ms.
// $('#example').mClick(timeout, clickTimes, callback) $(function(){ $('#example').mClick(800, 3, function(){ // You just clicked 3 times. }) });
This awesome jQuery plugin is developed by 2xiao. For more Advanced Usages, please check the demo page or visit the official website.