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

180
Visualizações
Why the value didn't set but the dispatch event run?

i have this code to set an input then click the button. i tried run the code by removing the dispatchEvent and num is set, when i run it with the dispatchEvent it didn't set the input value but the dispatchEvent works. Should i add a delay to execute set value then dispatchEvent? or separate it? How to fix this? Thank you!

const inits = function(){
  const injectElement = document.createElement('div');
  injectElement.className = "my-button";
  injectElement.id = "bigBtn";
  $('body').append(injectElement);

  spn = '<span class="big-span"></span><span class="small-span">Auto Fill</span><button class="btn btn-white" id="fillBtn" type="button">Fill</button>'
  $('#bigBtn').append(spn);
}
inits();

$('#fillBtn').click(function (e) { 
  e.preventDefault();
  num = 123;
  document.querySelector('input.arco-input').value = num;
  document.querySelector('.i18n-icon-search').dispatchEvent(new Event('click',{bubbles:true}));
});
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