jQuery事件检测-用鼠标删除输入框文本,将文本拖到输入框 [英] jQuery event detection - delete input box text with mouse, drag text to input box

查看:101
本文介绍了jQuery事件检测-用鼠标删除输入框文本,将文本拖到输入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码检测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

  1. 用鼠标删除输入框文本
  2. 将文本拖动到输入框
  3. 将文本拖离输入框
  4. 从鼠标上下文菜单或表单编辑"菜单中撤消操作

我尝试在mousedownmouseup上绑定,但是不起作用

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 with http://jsfiddle.net/9aRxb/1/

这篇关于jQuery事件检测-用鼠标删除输入框文本,将文本拖到输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆