Refresh the page after 3 clicks on the button

Asked

Viewed 35 times

1

I developed a code in Javascript that generates a sequence of random numbers and I wanted to know if I can put a limit of 3 clicks on this button and after the 3rd click the page is updated. I’ve tried using the history.go function only it updates right when you click, not after 3 clicks

That’s the button code:

<center><button onclick="history.go(0)">Clique e gere o código</button></center>

there is some way to make history.go be called only after 3 clicks?

1 answer

0


You couldn’t write a script for this?

In this way:

let clicks = 0;

function clickFunction() {
  clicks += 1;

  if (clicks >= 3) {
    console.log('Clicou mais de 3 vezes!');

    // agora voce executa o history.go(0)
    // window.history.go(0)
  }
}
<center>
  <button onclick="clickFunction()">Clique e gere o código</button>
</center>

Did you ever try it that way? I’m not sure I understand your question, but take the test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.