+ 2

Why both if else statement executed

Hi Look at my js code Both else and if statement is executed You find this from alerts i have used in the end of if and else blocks ! How can i debug this? https://code.sololearn.com/WOyG0yk3UQSy/?ref=app

22nd May 2020, 4:04 AM
Sadegh karimi sis
1 Antwort
+ 3
<label class="switch"> <input id="switch" type="checkbox"> <span class="slider round"></span> </label> $("#switch").click(function(){ The event is being set for the label and the child element input firing the event twice when clicked. Instead just set the event for the child element and then your code will work.
22nd May 2020, 5:34 AM
ChaoticDawg
ChaoticDawg - avatar