简体   繁体   中英

Mouse events in JavaScript?

How would I go about making an image follow the mouse using JavaScript? I'm currently working with the new HTML5 canvas element. (The image I want the mouse to follow is on the canvas, I just want it to follow the mouse's position.)

You can tie the image's position to the onmousemove event, you can see my demo here for doing that with regular JavaScript: http://jsbin.com/ogabi3/2

Things like jQuery UI's position utility will help provide collision detection with the browser

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