-1

How to disable a button if the button is clicked 10 times in less than 2 minutes.

But if the button is clicked 10 times in more than 2 min i what the counter to continue to count , i want to disable the button only if it is is clicked 10 times in less than 2 minutes . HOW CAN I DO THAT USING JAVASCRIPT CSS HTML . ? thank you.

Can you show me a demo or an example script. Thank you!

HERE A CODE .

<button id="BUTTON" ></button>
document.getElementById('button').onclick = function() { buttonClicked(); myFunction() }
var myVar;
function myFunction() { myVar= window.setInterval(120000); }
function buttonClicked() { if (totalCount + accCounter> 9) { document.getElementById("clap").disabled = true; } }
CIAO
  • 1
  • 3

1 Answers1

0

var myVar;
var totalCount=0;
accCounter=0;

document.getElementById('BUTTON').onclick = function() { buttonClicked(); totalCount+=1; console.log("total",totalCount); }

function myFunction() { myVar= window.setInterval(120000); }
function buttonClicked() { if (totalCount + accCounter> 9) { document.getElementById("BUTTON").disabled = true; } }
<button id="BUTTON" ></button>
Olaru Alina
  • 458
  • 4
  • 8
  • Thank you but i want the counter to continue counting after the 2 minutes interval from where it left i mean from click nine. – CIAO Jan 21 '21 at 14:15