disable double click on every site?

2

Is it possible to disable double click on the entire site and on any element? Is it possible with jQuery or HTML? I want to prevent the user from giving 2 clicks in a row on links, buttons and etc.

    
asked by anonymous 28.03.2017 / 16:40

1 answer

3

You can disable the button element eg. after click and enable it again after 2 seconds (eg)

function myFunction(e) {
    document.getElementById("linha").innerHTML += "<p>adicionado linha</p>";

    //Desabilita o botao
    e.disabled = true;
    
    //Habilita novamente após dois segundos (2000) ms
    setTimeout(function(){
      toggleDisabled(e)
    },2000);
}

function toggleDisabled(elem){
  elem.disabled = !elem.disabled;
}
<p>Texto de testes</p>
<button onclick="myFunction(this)" id="btn">Clique</button>
<div id="linha"></div>
    
28.03.2017 / 17:56