title: JavaScript: How prevent dblclick (Double Click) to also fire a single click event
body: <p>I want avoid that double click also fire a single click event.</p>
  
  <p>A simple solution i found is to delay the click with a timer and destroy the timer if a double click is fired.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var pendingClick;
  
  function myclick(){
     clearTimeout(pendingClick);
     pendingClick = setTimeout(function(){
        console.log('click');
     }, 500);
  }
  
  function mydblclick(){
    clearTimeout(pendingClick);
    console.log('double click');
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div onclick="myclick()" ondblclick="mydblclick()"&gt;Double Click Me!&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But this solution is based on timing, if the double click is too slow (>500ms) it also fire a single click.</p>
  
  <p>There is a stable solution for handle both click and double click?</p>