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

96
Vistas
Activating alternate <script> tags

Suppose I have a web document with alternate content, that is, if some condition is met, it should display content A, and if the condition isn't met, it should display content B. That's easy to implement - I wrap each content with a <div> tag, setting its style to display:none, and have some JS code that changes one of them to displayed according to the condition.

But suppose content A and content B aren't just plain html. Each of them contains <script> tags. I want these scripts to be in effect only if the corresponding content is displayed, that is, if my condition is met, I want all the <script>s in content A to be in effect, and all the <script>s in content B to be ignored, and vice versa.

Actually there're two questions here. Firstly, i want the <script>s in (say) content A to be compiled (and run) only when I tell them so, that is, after I decide that my condition is true. Secondly, when the condition becomes false, I want all the functions defined in these scripts to be undefined, and instead of them, I need to compile and run all the scripts in content B (the condition may become true again later, and then false again, and so on).

How can I do it?

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