Live-bound events in jquery and unbind

Source: Internet
Author: User

A $.fn.live repeated binding

Solve:

Using the Die () method, before the live () method is bound, unbind the previously bound event on this element, and then bind the new event through the Live () method.

The code is as follows Copy Code
First through the Die () method, and then through Live () binding
$ ("#selectAll"). Die (). Live ("Click", Function () {
Event Run code
});


Second, unlock live-bound events

Workaround: Use the Unbind ("click") method to unbind the event before binding the new event, that is, to remove the original event on the object before binding the event on the object

The code is as follows Copy Code

var accoutedit=function () {
$ (this). Text ("Unbind event");
Unlock Live Bindings
$ ('. Setaccoutedit. option '). Die (' click ', Accoutedit);
}

Binding modification Events
$ ('. Setaccoutedit '). Live (' click ', Accoutedit);

/* Shutdown function *
$ ('. Editoption '). Live (' click ', function () {

$ (this). Text ("Add binding Event");
Add Accoutedit Binding
$ ('. Setaccoutedit. option '). Live (' click ', Accoutedit);

});

Other than that
Using Bind-bound events, unbind with unbind
Using delegate-bound events, unbind with Undelegate
Using on-bound events, unbind with off

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.