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

170
Views
How to trigger ReactJs onChange event using Chrome extension content script

I'm writing a Chrome extension to autofill a text input on a website and hit enter to send a message.

The first thing I did was settings the value of the textbox.

const textbox = document.querySelector("#consumerInput")
textbox.value = "Hello";

But the text input clears out whenever I click somewhere else. I checked the website using React Developer tools extension and saw that it triggers a function on onChange event.

Then I tried to trigger onChange event using JQuery

    $(textBox).trigger("change");

And also doing a keyboard event

element.dispatchEvent(new KeyboardEvent("keydown", {
    key: "e",
    keyCode: 69, // example values.
    code: "KeyE", // put everything you need in this object.
    which: 69,
    shiftKey: false, // you don't need to include values
    ctrlKey: false,  // if you aren't going to use them.
    metaKey: false   // these are here for example's sake.
}));

but no luck.

can you guys help me? Thanks

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!