JQuery1.8 is used to determine whether an element is bound to an event. jquery1.8 is bound to an event.

Source: Internet
Author: User

JQuery1.8 is used to determine whether an element is bound to an event. jquery1.8 is bound to an event.

On previous versions, you can call it like for other data:

Obj. data ('events ');

In jQuery 1.8, this direct access was removed, so in recent versions you must call it like this:

$. _ Data (obj [0], "events ")

In general, the version can use obj. data ('event'). In JQuery1.8, the obj. data method is canceled and changed to the $. _ data method.

Note: In $. _ data (obj [0], "event"), obj [0] must be added with the array [0] subscript. Otherwise, no data can be obtained.
------- The following is an example

<Html xmlns = "http://www.w3.org/1999/xhtml"> 


How can I use jQuery to determine whether an event is bound to an element?

For details about how to determine whether an event is bound, refer. The research found that all events were initiated. In fact, it was also designed to prevent memory overflow and the speed of page unload, as well as to trigger multiple functions and facilitate management. For details, refer to this article. JQuery will unmount all bound events during window. unload to release the memory. To determine whether an event has been bound to an element, use the following statement: view sourceprint for dededecms training on Alibaba Cloud? JQuery. data (elem, "events") [type] // the old version can also use $ (elem ). data ("events") [type] // 1.2.3 before using 51hsycn return value:
An Object can be traversed using for in. Or undefined.
Parameter: elem is an object and type is an event type.
For example, determine whether a click event is bound to an element whose id is foo:

JQuery checks whether an event is bound to an element.

To determine whether an event has been bound to an element, use the following statement jQuery. data (elem, "events") [type] // the old version can also use $ (elem ). data ("events") [type] // 1.2.3 before return value: an Object can be traversed using for in. Or undefined. Parameter: elem is a DOM object and type is an event type. For example, determine whether a click event if ($ ("# foo") is bound to an element whose id is foo "). data ("events") ["click"]) {// your code}

Related Article

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.