0
HELP me to understand where is the bug in my js code??
hi there i am desigining a web site that hast two theme that they change by the toggle elemet in top of the website. i build a var and change use if statment to know what theme know gonna show up but my code does n't run. where is the bug of my code ??? https://code.sololearn.com/WOyG0yk3UQSy
1 Answer
0
Change $('.switch').click to $('.slider').click
The problem is event propagation. Clicking the slider makes the switch click event to also be called making it seem like the switch was clicked twice. This can be solved by making your click event handler return false but that will mean the slider won't slide. So the best thing is to change $('.switch').click to $('.slider').click