只有鼠标左键jQuery的鼠标松开功能? [英] jQuery mouseup function on left mouse button only?
本文介绍了只有鼠标左键jQuery的鼠标松开功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个元素,它动画在鼠标松开
的功能,但现在,它同时适用于左和右键。有没有办法只能使用离开按钮?
$(文件)。就绪(函数(){
$(格)。鼠标松开(函数(){
顶部:-101%
});
});
解决方案
您可以检查,看看哪些鼠标按键使用 e.which
(pressed 1
是主要的, 2
是中部和 3
是次要的):
$(文件)。就绪(函数(){
$(格)。鼠标松开(函数(五){
如果(!e.which = 1)返回false; //停止所有非左点击 ...
});
});
I have this element which animates on a mouseup
function, but right now, it works for both the left and right buttons. Is there any way to only use the left button?
$(document).ready(function() {
$("div").mouseup(function() {
top: "-101%"
});
});
解决方案
You can check to see which mouse button was pressed using e.which
(1
is primary, 2
is middle and 3
is secondary):
$(document).ready(function() {
$("div").mouseup(function(e) {
if (e.which != 1) return false; // Stops all non-left-clicks
...
});
});
这篇关于只有鼠标左键jQuery的鼠标松开功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文