How to populate React-generated input fields with JQuery

前端 未结 2 499
离开以前
离开以前 2021-01-27 03:23

I\'m trying to write a bookmarklet to autofill a form, to simplify manual testing. The site is implemented in React. I\'ve tried using JQuery, for example:

$(\"#         


        
2条回答
  •  离开以前
    2021-01-27 03:50

    //find element
    let elem = document.querySelector("#emailAddress");
    //create event
    let event = new Event('input', { bubbles: true });
    //set value
    elem.value="bob@example.com";
    //trigger event
    elem.dispatchEvent(event)
    

提交回复
热议问题