Trigger onmouseover event programmatically in JavaScript

前端 未结 8 688
庸人自扰
庸人自扰 2020-11-27 18:58

Is there a way to programmatically trigger the onmouseover event in plain JavaScript? or \"extract\" the method from the onmouseover event to call

8条回答
  •  被撕碎了的回忆
    2020-11-27 19:35

    I needed to do something similar, but I'm using jQuery, and I found this to be a better solution:

    Use jQuery's trigger function.

    $j('#top-div' ).trigger( 'mouseenter' );
    

    You can also add parameters to it if you need to. See the jQuery documentation on .trigger.

提交回复
热议问题