- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
在尝试使用 jquery 检测鼠标右键单击时,我注意到单击鼠标右键似乎不会触发 click 事件处理程序,而 mousedown 或 mouseup 事件处理程序会触发。
例如,右键单击测试 div 后,以下警报“正在测试!”:
$('#test').mousedown(function(e) {
alert('testing');
});
但是,以下不会:
$('#test').click(function(e) {
alert('testing!');
});
有人知道为什么吗?
最佳答案
当你按下 mousedown 时,even fired 有 event.which
取自此处:How to distinguish between left and right mouse click with jQuery
$('#element').mousedown(function(event) {
switch (event.which) {
case 1:
alert('Left mouse button pressed');
break;
case 2:
alert('Middle mouse button pressed');
break;
case 3:
alert('Right mouse button pressed');
break;
default:
alert('You have a strange mouse');
}
});
因此不要使用 .click(),而是使用 mousedown 并检查大小写。
关于javascript - 无法使用 jquery 的单击事件处理程序来检测右键单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7343117/
我有点困惑。在 : http://delphi.about.com/od/objectpascalide/l/blvkc.htm 它说“Space”的正确键是#20。试过了,但行不通。但是,将其替换为
我有一个 input 的 type="submit" 并且我希望当我点击(右键或左键点击)它时这个元素周围没有蓝色边框。 我在下面的chrome浏览器中添加了OK模式和not OK模式的图片: OK模
我想在右键单击选项卡标题时显示上下文菜单条。 但是,我没有找到检测选项卡标题点击的方法。 有人知道如何做到这一点吗? 最佳答案 Private Sub tab1_MouseClick(sender A
我对编程还很陌生,正在尝试制作扫雷 GUI。游戏完美地右键单击 JToggleButton,在按钮上显示了一个代表炸弹的“B”,但是当我在鼠标监听器中用 setIcon() 替换 setText()
我正在尝试将一个按钮 float 到卡片的右侧。我希望它出现在右下角。 当我正确使用 float 时。它出现在父 div 之外,有没有办法正确定位它?
我正在使用 Struts2 标签和下面的代码使用 JS 计算并检查/验证在文本字段中输入的值。 它还会更新在 textfield 中输入的总数列表,这些由 onblur 处理和 onkeydown事件
我是一名优秀的程序员,十分优秀!