寻找 jQuery 事件类型的完整列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2924173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 14:32:55  来源:igfitidea点击:

Looking for a full list of jQuery event types

jqueryeventsdom-events

提问by serg

Where I can find a complete list of all jQuery supported events (like click, mouseupetc) with some explanations when they are triggered? I am looking for those that can be binded:

我在哪里可以找到所有的jQuery支持的事件(如的完整列表clickmouseup与一些说明等),它们被触发时?我正在寻找那些可以绑定的:

$('#foo').bind('click', handler);

For example I just found out by accident that there is pasteevent but I can't find any references to it anywhere in their docs. What else is there?

例如,我只是偶然发现有paste事件,但我在他们的文档中的任何地方都找不到任何对它的引用。那里还有什么?

采纳答案by Andy E

A non exhaustive list is at http://api.jquery.com/category/events/. There are more DOM events supported through .bind()and .live(). Those functions can assign a handler to any standard DOM event, most of which are listed along with compatibility tables at http://www.quirksmode.org/dom/events/

一个非详尽列表位于http://api.jquery.com/category/events/。通过.bind()和支持更多 DOM 事件.live()。这些函数可以为任何标准 DOM 事件分配一个处理程序,其中大部分与兼容性表一起在http://www.quirksmode.org/dom/events/列出

The .bind() method is the primary means of attaching behavior to a document. All JavaScript event types, such as focus, mouseover, and resize, are allowed for eventType.

.bind() 方法是将行为附加到文档的主要方法。eventType 允许所有 JavaScript 事件类型,例如焦点、鼠标悬停和调整大小。



As of jQuery 1.7, you should use .on()in place of .live()and .bind().

在jQuery 1.7中,你应该使用.on()的地方.live().bind()

回答by Andres

MDN has a good overview of majority of the standard and non-standard events

MDN 对大多数标准和非标准事件有很好的概述

https://developer.mozilla.org/en-US/docs/Web/Reference/Events

https://developer.mozilla.org/en-US/docs/Web/Reference/Events

回答by afasdfasdf

You can check out the full list of jQuery events: http://api.jquery.com/category/events/

您可以查看 jQuery 事件的完整列表:http: //api.jquery.com/category/events/

But regarding the pasteevent you mentioned, jQuery can also bind to standard DOM events. A good list is provided by MDN https://developer.mozilla.org/en-US/docs/Web/Events

但是关于paste您提到的事件,jQuery 也可以绑定到标准 DOM 事件。MDN https://developer.mozilla.org/en-US/docs/Web/Events提供了一个很好的列表

回答by MarquisBS

I know this question is pretty old. But for the sake of giving an updated and complete answer to this question.

我知道这个问题已经很老了。但是为了对这个问题给出更新和完整的答案。

The shortcut methods are always named the sameas the event names used in any of the on()/bind()/live() methods.

快捷方法的名称始终与任何 on()/bind()/live() 方法中使用的事件名称相同

So if you want to use any shortcut event feature but with on()/bind()/live() you can just take the method name, ommit the brackets and put it in quotes like so: "eventname"/'eventname'. They should behave the same.

因此,如果您想使用任何快捷事件功能,但使用 on()/bind()/live() ,您可以只使用方法 name,省略括号并将其放在引号中,如下所示:"eventname"/'eventname'。他们应该表现得一样。

So for example: .dblclick() -> 'dblclick' =>

例如:.dblclick() -> 'dblclick' =>

$('a').on('dblclick', function() {  
    console.log("I got double clicked");
});

http://api.jquery.com/category/events/is a complete list of event methods. (Yes I know I'm not the only one pointing to this site but together with my explanation it actually is a complete list of events for 'on'/'live'/'bind')

http://api.jquery.com/category/events/是事件方法的完整列表。(是的,我知道我不是唯一一个指向这个站点的人,但连同我的解释,它实际上是一个完整的“on”/“live”/“bind”事件列表)

If you have the chance to use on() you should do so since on() does the same and all calls to 'bind' and 'live' actually call the 'on' function. Here is more prove about this: What's the difference between `on` and `live` or `bind`?

如果你有机会使用 on() 你应该这样做,因为 on() 做同样的事情,所有对 'bind' 和 'live' 的调用实际上都调用了 'on' 函数。这里有更多关于这一点的证明:“on”和“live”或“bind”有什么区别?

Also some people asked about the touch (mobile) events. I generally recommend to get used to the on() event method because according to the jQuery mobile documentationthis is the only way to register touch events on html elements, which is on par with jQuery's future api plans to remove bind()/live() and all the shortcut event methods.

还有一些人询问了触摸(移动)事件。我通常建议习惯 on() 事件方法,因为根据jQuery mobile 文档,这是在 html 元素上注册触摸事件的唯一方法,这与 jQuery 未来移除 bind()/live() 的 api 计划相当) 和所有快捷事件方法。

回答by InfiniteStack

This page lists all events that work in all browsersto my knowledge. You will not find the "paste" event here, because, as others pointed it out, it doesn't work in all browsers.

据我所知此页面列出了在所有浏览器中工作的所有事件。您不会在这里找到“粘贴”事件,因为正如其他人指出的那样,它不适用于所有浏览器。

http://www.authenticsociety.com/jquery/list-all-jquery-events.html

http://www.authenticsociety.com/jquery/list-all-jquery-events.html