Javascript with jQuery: Click and double click on same element, different effect, one disables the other

The general idea:

  1. Upon the first click, dont call the associated function (say single_click_function()). Rather, set a timer for a certain period of time(say x). If we do not get another click during that time span, go for the single_click_function(). If we do get one, call double_click_function()

  2. Timer will be cleared once the second click is received. It will also be cleared once x milliseconds are lapsed.

BTW, check Paolo’s reply out: Need to cancel click/mouseup events when double-click event detected
and of course the entire thread! 🙂

Better answer: https://stackoverflow.com/a/7845282/260610

Leave a Comment