如何记录一个元素在jQuery中触发的所有事件? [英] How do you log all events fired by an element in jQuery?

查看:98
本文介绍了如何记录一个元素在jQuery中触发的所有事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望看到用户与其进行互动的输入字段触发的所有事件。这包括以下内容:

I'd like to see all the events fired by an input field as a user interacts with it. This includes stuff like:



  1. 点击它。

  2. 点击关闭它。

  3. 选择它。

  4. 从其中选择。

  5. Ctrl + C Ctrl + V

  6. 右键单击 - >粘贴

  7. 右键单击 - >剪切。

  8. 右键单击 - >复制

  9. 拖放文本从另一个应用程序。

  10. 使用Javascript修改它。

  11. 使用调试工具(如Firebug)进行修改。

  1. Clicking on it.
  2. Clicking off it.
  3. Tabbing into it.
  4. Tabbing away from it.
  5. Ctrl+C and Ctrl+V on the keyboard.
  6. Right click -> Paste.
  7. Right click -> Cut.
  8. Right click -> Copy.
  9. Dragging and dropping text from another application.
  10. Modifying it with Javascript.
  11. Modifying it with a debug tool, like Firebug.


我想使用 console.log 显示它。这是否可能在Javascript / jQuery中,如果是这样,我该怎么做?

I'd like to display it using console.log. Is this possible in Javascript/jQuery, and if so, how do I do it?

推荐答案

$(element).on("click mousedown mouseup focus blur keydown change",function(e){
     console.log(e);
});

这将为您提供很多(但不是全部)关于事件触发的信息。 ..除了手动编码这样,我不能想到任何其他方式来做到这一点。

That will get you a lot (but not all) of the information on if an event is fired... other than manually coding it like this, I can't think of any other way to do that.

这篇关于如何记录一个元素在jQuery中触发的所有事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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