简体   繁体   English

JavaScript中的鼠标事件?

[英]Mouse events in JavaScript?

How would I go about making an image follow the mouse using JavaScript? 如何使用JavaScript使图像跟随鼠标移动? I'm currently working with the new HTML5 canvas element. 我目前正在使用新的HTML5 canvas元素。 (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 您可以将图像的位置绑定到onmousemove事件,您可以在此处查看我的演示,以使用常规JavaScript进行演示: http : //jsbin.com/ogabi3/2

Things like jQuery UI's position utility will help provide collision detection with the browser 诸如jQuery UI的position实用程序之类的东西将有助于提供与浏览器的碰撞检测

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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