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

93
Visualizações
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 à 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