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

191
Visualizações
How to set injected function at the very bottom of website?

I have a website that load some JS code from url which have select2() function, but i don't know why I can't call or use it using injected script (chrome extension) and got Uncaught TypeError: $(...).select2 is not a function. But I can run JQuery syntax by the injected script, the difference is JQuery.min.js script loaded inside the <head> tag but that select2 script is inside the <body> tag. Is there any way to access selec2() function without changing the website (like rearrange the script or others)? thank you!

This are the script of my custom chrome extension

const batchscp = function(){
  const injectElement = document.createElement('div');
  injectElement.className = "custombtn btn";
  injectElement.id = "mybtn";
  $('body').append(injectElement);

  spn = //many html elements to inject which contain a button with id=auto
  $('#mybtn').append(spn);
}
batchscp();

$('#auto').click(function (e) { 
  e.preventDefault();
  $('.select2').select2(); //Uncaught TypeError: $(...).select2 is not a function
  $('#logisticsAdd').val('65').trigger('change');
});
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