How to use both onclick and ondblclick on an element?

Like Matt, I had a much better experience when I increased the timeout value slightly. Also, to mitigate the problem of single click firing twice (which I was unable to reproduce with the higher timer anyway), I added a line to the single click handler:

el.onclick = function() {
    if (timer) clearTimeout(timer);
    timer = setTimeout(function() { alert('Single'); }, 250);        
}

This way, if click is already set to fire, it will clear itself to avoid duplicate ‘Single’ alerts.

Leave a Comment

tech