Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

270
Visualizações
How to change loading state button with JS?

I am redirecting to another page with anchor tag and when the button is clicked I use some javascript to show loading spinner inside the button:

//Example
const a = document.getElementById("some_id");
a.innerHTML = //here I place some divs to show the spinner

My problem is that when I try it on mobile the button is changing its state and redirecting, but when I hit back and go back to the same page, the state is persisted and the button is still in loading state.

I tried using some lifecycle hooks like "beforeunload", "unload" to change the button then, but it's not working. I have also tried to use

document.addEventListener("DOMContentLoaded", function() {//some code to bring back state})

but I still don't have success. This is not a problem on desktop. But on mobile it's acting like SPA and when I hit back the state is persisted...

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda