This article mainly introduces the quick solution for repeated jquery event binding. If you need a friend, please refer to it and hope to help you.
One $. fn. live repeat binding
Solution:Use the die () method to unbind all events bound to the element before binding the live () method, and then bind new events using the live () method.
The Code is as follows:
// Unbind from the die () method and then use live () Binding
$ ("# SelectAll"). die (). live ("click", function (){
// Event Running code
});
Second click and other events
Solution:The unbind ("click") method is used to unbind the Bound event and then bind the new event. That is, the original event on the object is removed before the event is bound to the object.
Complete Test code:
The Code is as follows:
Repeat the binding trigger button(Click this button twice or more to trigger repeated binding, and then click the button below to see the result)
Click to repeat the binding test button
Click to bind a test button
Repeat the test button in live.
Live binds a test button