Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!