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

110
Visualizações
I want to upload random script.js files into one script tag?

I want to upload random script files into a script tag element. I Have tried this but it didn't work.

var randomTest = Math.floor(Math.random() * 5) +1; //generating random number
var randomTestJs = "test" + randomTest + ".js"; // targeting random question file source
var questionSource = "js/" + randomTestJs; //selecting question file source
var test = document.querySelectorAll("script")[0]; //selecting tag attribute
test.setAttribute("src", questionSource); //overwriting question file
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

this can't work. the script tags are executed when the side will be loaded. you try to run the scripts on the fly. this is not the way it works.

perhaps you try to load your questions in a json format with fetch and than work with it.

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