Trigger An Event When Clicking X Times - xclick

File Size: 9.52 KB
Views Total: 344
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Trigger An Event When Clicking X Times - xclick

xclick is an advanced click event handling jQuery plugin that enables you to perform a function when an element is clicked a certain number of times.

See Also:

How to use it:

1. Load the core JavaScript file index.js after jQuery (slim build is recommended).

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/index.js"></script>

2. Attach the function xclick to the element and set the number of clicks that trigger the event. In this example, you will receive a notification when you click on this element three times in a row.

<button id="example">
  Click Me 3 Times
</button>
$(function(){
  $('button').xclick(3, () => {
    alert('Clicked 3 times in a row!');
  });
});

Changelog:

v1.0.6 (2022-04-07)

  • Add support for chaining
  • Add a type definition

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