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

156
Vistas
Rerun scripts/functions on tab change or hashchange?

I'm running an instance of Moodle that separates the page contents into a lazyloading tab-like fashion, where the contents of a section are only loaded once the link is clicked by the user (but remain loaded thereafter, I think).

I have identical functions I want ran on each tab's content, but of course, the scripts loaded at the $(window).ready and $(document).ready levels have already ran. Right now I have duplicate scripts living and loading individually from each tab, but I hate it and feel like it must be effecting performance.

How can I re-run my function(s) on each tab after it's been clicked? I don't want to reload the page, just prod the scripts into running again. Since the page URL registers an anchor fragment for each link, I think the answer is a hashchange event but I don't know how to write it, or if it needs a listener? I'm so new to JS and jQuery outside of styling and basic functions. For example, I've tried

$(document).ready(function() {
  //attaching the event listener
  $(window).on('hashchange', function() {
    $('#item').addClass('myClass')
  }).trigger('hashchange');
});

I'm wondering if there's a variable or other syntax I need to include? Thank you so much for looking! I appreciate any help!

about 4 years ago · Juan Pablo Isaza
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