admin管理员组文章数量:1403443
I want to know if a user stops pressing a button. So I capture the $button.mouseup(...) and $button.mouseout(...) events. However, I want the mouseout event to only matter when the user is still pressing the mouse- Otherwise, it will fire whenever the user passes over the button.
Any ideas?
I want to know if a user stops pressing a button. So I capture the $button.mouseup(...) and $button.mouseout(...) events. However, I want the mouseout event to only matter when the user is still pressing the mouse- Otherwise, it will fire whenever the user passes over the button.
Any ideas?
Share Improve this question asked May 17, 2011 at 16:53 YarinYarin 184k155 gold badges410 silver badges524 bronze badges 1-
You can just set a global variable to
true
on mousedown and get that value onmouseout
. – pimvdb Commented May 17, 2011 at 16:55
2 Answers
Reset to default 8Check e.which
, which indicates the pressed button.
A quick and dirty method would be to use globals (or closures; some way of giving both the mouseup
and the mouseout
functions access to the same variable):
var mouseIsUp = true,
onMouseUp = function () {
mouseIsUp = true;
// ...
},
onMouseDown = function () {
mouseIsUp = false;
},
onMouseOut = function () {
if (!mouseIsUp) {
// ...
}
};
本文标签: javascriptCheck if mouse is down on a mouseout event jQueryStack Overflow
版权声明:本文标题:javascript - Check if mouse is down on a mouseout event- jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744417362a2605264.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论