JSFiddle - React, Tailwind, and code Playground
by Matt Ball
HTML
<button id="clkDblClk">Click me</button>
<pre id="out"></pre>
JavaScript
var $out = $('#out'),
text = [];
$('#clkDblClk').click(function() {
var clickTimer = setTimeout(function() {
// noop
}, 1000);
$(this).data('clickTimer', clickTimer);
log('CLICK: saving timer ID: ' + clickTimer);
}).dblclick(function() {
var clickTimer = $(this).data('clickTimer');
clearTimeout(clickTimer);
log('DOUBLECLICK: cancelling timer ID: ' + clickTimer);
});
function log(s) {
text.push(s);
$out.text(text.join('\n'));
}