简体   繁体   中英

Programmatically call “mousemove” event in JS

Is there a possibility to programmatically call the mousemove event in jQuery? Obviously, I'm not going to change the actual position of the cursor - it's impossible. All I want is re-call this event so all other scripts that have attached their handers to it will also be called.

To trigger event handlers bound to the mousemove event you can use trigger()

$('#elementID').on('mousemove', function() {
     // do stuff
});

$('#elementID').trigger('mousemove'); // triggers above event handler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM