JQuery determines whether the element is bound with Event _ jquery

Source: Internet
Author: User
For details about how to determine whether an event is bound, refer. After studying it, I found that jQuery caches events to prevent memory overflow and the speed of page unload, including multiple function triggers, convenient management and many other benefits. For details, refer to this article.
JQuery will unmount all bound events during window. unload to release the memory.

OK. Use the following statement to determine whether an event has been bound to an element:

The Code is as follows:


JQuery. data (elem, "events") [type] // the old version can also be used.
$ (Elem). data ("events") [type] // 1.2.3 later


Return Value:
An Object can be traversed using for in. Or undefined.
Parameters:
Elem is a DOM object and type is an event type.
Example:
Determine whether a click event is bound to an element whose id is foo.

The Code is as follows:


If ($ ("# 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.