Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Prevent double click!
// jQuery plugin to prevent double click
jQuery.fn.preventDoubleClick = function() {
$(this).on('click', function(e){
var $el = $(this);
// Previously clicked, stop actions
// Mark to ignore next click
$'clicked', true);
// Unmark after 1 second
}, 1000)
return this;
Copy link

RabkinAlex commented Feb 24, 2015

How we can use it ? exampe please

Copy link

ultimania92 commented Mar 23, 2015

I could give an example.

On a website I'm building, we hit a problem where if the user clicked on a tab too much to refresh it, sometimes a list would post twice due to ajax calls. Implementing a double click check would control for that so it doesn't happen again.

Copy link

SindlaXYZ commented Dec 17, 2020

How we can use it ? exampe please

@RabkinAlex With the code above, and this:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment