Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda