Let's look at an example:
Html:
1 <Body>2 <ButtonID= "BTN">Button</Button>3 <ButtonID= "BTN1">Button 1</Button>4 </Body>
Javascript:
1 <script src= "Https://cdn.bootcss.com/jquery/2.2.3/jquery.js" ></script>2 < Script>3 $ (' #btn '). Click (function() {4 alert (1)5 $ (' #btn1 '). Click (function() {6 alert (2); 7 })8})9 </script>
Click the button #btn two times will pop up two times 1, then click 1 times #btn1 but popped two times 2, this is the event overlay problem in jquery, the following is said the solution
1 <script src= "Https://cdn.bootcss.com/jquery/2.2.3/jquery.js" ></script>2 < Script>3 $ (' #btn '). Click (function() {4 alert (1)5 $ (' #btn1 '). Off (' click '). Click (function() {6 alert (2); 7 })8})9 </script>
So you click on the #btn1 only pop up once 2, no matter how many times you #btn click, then click #btn1 will only get the most recent binding on the #btn1 body Click event, before all are untied
Pay tribute to the pit I met, from now on I wish the lake no such pit.
About jquery Click event Overlay Problem