One $.fn.live repeat Binding
Workaround: Use the Die () method to dismiss the previously bound event on this element before the live () method binding, and then bind the new event through the Live () method.
// The Die () method is first removed, and then the $ ("#selectAll") is bound by Live (). Die (). Live ("Click",function() {/// event run Code });
Two Click and other events
Workaround: Use the Unbind ("click") method to unbind the event before binding the new event, that is, remove the original event on the object before binding the event to the object
Complete test Code:
<div class= "box" > <button id= "Test" > Duplicate binding Trigger button </button> (Click this button two times and above to trigger a duplicate binding, then click on the button below to see the result) <br/><br/> <button id= "test1" >click repeat binding Test button </button> <button id= " Test2 ">click bind once Test button </button> <button id=" test3 ">live repeat bind Test button </button> <butt On id= "Test4" >live bind once Test button </button> </div> <script type= "Text/javascript" src= "... /static/jquery-1.6.1.min.js "></script> <script type=" Text/javascript "> $(function(){ vari = 1,j=1,k=1,h=1,n=1; varTriggerbind =function(){ $("#test1"). Click (function() {alert ("Click does not unbind the duplicate binding to execute the" + j + + "Times"); }); $("#test2"). Unbind (' click '). Click (function() {alert ("Click Unbind Execution" + k++ + "Times"); }); $("#test3"). Live ("click",function() {alert ("Live does not unbind repeat" + h++ + "Times"); }); $("#test4"). Die (). Live ("click",function() {alert ("Live unbind and Execute" + n++ + "Times"); }); } $("#test"). Click (function() {triggerbind (); Alert ("Trigger binding Point hit" + i++ + "Times"); }); }); </script>