+ 1
What am I doing wrong?
Trying to make a toggle switch that moves left when true and right when false. How can I achieve this? https://code.sololearn.com/WYNAZpVJs42a/?ref=app
8 ответов
+ 5
https://code.sololearn.com/W41W6P3A2U0z/?ref=app
+ 3
You want the entire button to move, or do you want the colour to change by moving from left to right?
+ 3
Problem lies within your script. When you toggle the button, you set the innerHTML of the div, which overwrites your circle div, causing the circle to not display.
+ 2
You could use getElementsByClassName[0] instead, it's equivalent.
+ 1
I want to place a circle inside the red div that will move. But I can't get the circle to appear unless it's outside of the div.
+ 1
lol. forgot about that. I can fix.
+ 1
Now now how can I animate it from left to right and vice versa?
+ 1
Why did you use query selector?
Why not use getElementsByClassName?
Sorry about all the questions
new to coding xD