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