javascript 检测 HTML 画布元素的 mouseMove out 事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7977806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Detect mouseMove out event for HTML canvas element
提问by Amit Hagin
mouseMove event is for moving on the canvas itself, but I can't detect when the mouse leaves the canvas.
mouseMove 事件用于在画布本身上移动,但我无法检测鼠标何时离开画布。
Is there an option to detect when the mouse is moving out of the canvas?
是否可以选择检测鼠标何时移出画布?
回答by Jonas
Have you tried mouseout
?
你试过mouseout
吗?
element.addEventListener ("mouseout", myFunction, false);
回答by KBoek
Here's a list of all mouse events that apply to html elements: http://www.w3schools.com/tags/ref_eventattributes.asp(scroll down to Mouse Events).
以下是适用于 html 元素的所有鼠标事件的列表:http: //www.w3schools.com/tags/ref_eventattributes.asp(向下滚动到鼠标事件)。