How to trigger event in JavaScript?

前端 未结 18 2298
情深已故
情深已故 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:13

    I just used the following (seems to be much simpler):

    element.blur();
    element.focus();
    

    In this case the event is triggered only if value was really changed just as you would trigger it by normal focus locus lost performed by user.

提交回复
热议问题