[英]How to check if Y coordinates of mouse is greater than a value
我可以通过它检查鼠标的Y坐标。
$(document).mousemove(function(e) {
var MouseY = "( " + event.clientY + " )";
});
但是如何在大于某个值(例如20px)时触发函数。 我想这是行不通的
if (MouseY > 20){
alert('yes');
}
为什么不合并两个片段?
$(document).mousemove(function() {
var threshold = 20;
if(event.clientY > threshold) {
alert('Current mouse position is: ' + event.clientY);
// or call another function here like:
// react(event.clientY);
};
});
这就是你想要的吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.