How to trigger event in JavaScript?

前端 未结 18 1900
情深已故
情深已故 2020-11-21 04:48

I have attached an event to a text box using addEventListener. It works fine. My problem arose when I wanted to trigger the event programmatically from another

18条回答
  •  忘了有多久
    2020-11-21 05:10

    The most efficient way is to call the very same function that has been registered with addEventListener directly.

    You can also trigger a fake event with CustomEvent and co.

    Finally some elements such as support a .click() method.

提交回复
热议问题