开发者

Looking for a full list of jQuery event types

开发者 https://www.devze.com 2023-01-01 21:15 出处:网络
Where I can find a complete list of all jQuery supported events (like click, mouseup etc) with some explanations when they are triggered? I am looking for those that can be binded:

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

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

For example I just found out by accident that there is paste event but I can't find any references to it anywhe开发者_StackOverflow社区re in their docs. What else is there?


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/

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.


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


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

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


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

But regarding the paste event 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


This page lists all events that work in all browsers to 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


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 same as the event names used in any of the on()/bind()/live() methods.

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.

So for example: .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')

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`?

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 documentation this 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消