Determines whether an element is bound using jquery.

Source: Internet
Author: User

In some JS debugging that uses jquery, we may need to determine whether an element is bound to an event. If this element is bound using jquer, you can use the following method to check whether it is bound to an event.

VaR Tempe = $ ("# foo"). Data ("events ");
If (Tempe ){
If (Tempe ["click"]) {
// Your code
}
}

Principle: jquery caches events to prevent memory overflow and the speed of page unload. It also includes multiple function triggers and convenient management, for details, refer to this article.
Jquery will unmount all bound events during window. Unload to release the memory.

 

Well, if you use traditional event writing methods, such as <a onclick = "test ()">, you can only determine whether the element attribute exists in XXX.

 

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.