Not a long click, just a click, where are the mousedown and mouseclick far removed from each other? To solve this, you can simply measure the time it takes from the mousedown event to the click event and check if it is, for example. longer than two seconds (or whatever you want).
You can access the current milliseconds from 01/01/1970 via new Date().getTime() . Given that I would intuitively check for a "long click".
$(".selector").mousedown(function() { $(this).data("timestamp", new Date().getTime()); }).click(function(event) { var e = $(this); var start = e.data("timestamp"); e.removeData("timestamp"); if (start && new Date().getTime() - start > YOUR_DESIRED_WAIT_TIME_IN_MILLISECONDS) {
source share