Thoughts and examples of all events in jquery Uninstall

Source: Internet
Author: User
Tags anonymous delete cache

Native JS does not support anonymous uninstall events, jquery is useful for developers to support anonymous

Thoughts on anonymous Events

First she will determine whether the target is an element or an object, and if it is an element, mark the element with an identifier (expando) and then the value is a GUID generated and a cache is created under the cache object, such as:

$.cache={
' 2 ': {
data: {},
events: {},
handle:function () {}}
,
}



Then you will trigger the element event to take the identity of the elements to find in the cache, and there will be commissioned, selectors and other judgments, and then the final trigger, uninstall is actually taken in the cache handle uninstall, because it is a ...

If the target is not an element, such as a window, then she will add the logo directly to the target, for example: Window[$.expando]

Actually, the event has a very deep relationship with the cache.

Uninstall All Events

Empty identity

The identity here includes the elements and the objects on the

$ (' * '). Add (Window). each (function () {
try{
delete This[$.expando];
}catch (e) {}
});



PS: Because window is not an element, there are some events, such as scroll,resize, etc.

Delete Cache

The cache here includes the element's cache and the object cache

Window[$.expando] = {}
$.cache = {};


jquery Deletes an existing event instance


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.