Is there something in jquery that would allow me to differentiate between behavior on double click and single click?
When I bind both to same element only the single click gets executed.
Is there a way that wait for some time before execution of the single click to see if the user clicks again or not?
Thanks :)
Below is my simple approach to the issue.
JQuery function:
Implementation:
Inspect the clicked element in Firefox/Chrome to see data-clicks go up and down as you click, adjust time (1000) to suit.
i am implementing this simple solution , http://jsfiddle.net/533135/VHkLR/5/
html code
script code
its not much laggy
I made some changes to the above answers here which still works great: http://jsfiddle.net/arondraper/R8cDR/
Sure, bind two handlers, one to
click
and the other todblclick
. Create a variable that increments on every click. then resets after a set delay. Inside the setTimeout function you can do something...I found that John Strickler's answer did not quite do what I was expecting. Once the alert is triggered by a second click within the two-second window, every subsequent click triggers another alert until you wait two seconds before clicking again. So with John's code, a triple click acts as two double clicks where I would expect it to act like a double click followed by a single click.
I have reworked his solution to function in this way and to flow in a way my mind can better comprehend. I dropped the delay down from 2000 to 700 to better simulate what I would feel to be a normal sensitivity. Here's the fiddle: http://jsfiddle.net/KpCwN/4/.
Thanks for the foundation, John. I hope this alternate version is useful to others.
This solution works for me