问题描述
我可以使用以下代码检测cut, copy, paste
事件
I'm able to detect the cut, copy, paste
events with the following code
$('#searchInput').bind('cut copy paste', function (e) {
setTimeout("handleMouseEvents();", 10);
});
是否有可能检测到以下事件
Is it possible to detect the following events
- 用鼠标删除输入框文本
- 将文本拖动到输入框
- 将文本拖离输入框
- 从鼠标上下文菜单或表单编辑"菜单中撤消操作
我尝试在mousedown
和mouseup
上绑定,但是不起作用
I tried binding on mousedown
and mouseup
, but not working
$('#searchInput').bind('cut copy paste mousedown mouseup', function (e) {
setTimeout("handleMouseEvents();", 10);
});
推荐答案
我能够绑定到这些事件,以进行工作cut copy paste mousedown mouseup focus blur
I was able to get binding to work for these events cut copy paste mousedown mouseup focus blur
应该在删除,拖出,拖拽的情况下覆盖您,但是您不一定会知道字段已更改以及哪个绑定事件导致了更改的详细信息,我想您还必须保留制表符事件之间输入字段的当前/上一个值.
which should cover you on delete, drag out, drag in circumstances but you won't necessarily know that much detail just that the field has changed and which bound event caused the change, I think you'd also have to keep tabs on the current/previous value of the input field between events.
这是我正在玩的jsfiddle http://jsfiddle.net/9aRxb/1/
Here's the jsfiddle I was playing withhttp://jsfiddle.net/9aRxb/1/
这篇关于jQuery事件检测-用鼠标删除输入框文本,将文本拖到输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!