+ 6
A small bug, can anybody suggest a fix to it?
https://code.sololearn.com/Wc9dCb4XbB9Y/?ref=app Tapping on any added task should result in the switching of its text's strike-through status. But the first tap on every added task in the list doesn't do what is supposed (however, any subsequent taps do what is required). Please help.
3 Respuestas
0
I think your elem.style.textDecoration isn't immediately set to "none" on its creation. This means that, on its first click, since it isn't set to "none" it sets it to "none". Then it works on your second click.
Two ways to fix this I can think of:
1) Set task.style.textDecoration = "none"; in your add() method.
2) Change your if statement in your strike() method to
if (elem.style.textDecoration != "line-through") {
elem.style.textDecoration = "line-through";
}
else {
elem.style.textDecoration = "none"
}
Edit: I have no idea why someone downvoted me for this, but just to show but both ways work, I've done them.
https://code.sololearn.com/Wlu6tfBaN8rV/?ref=app
https://code.sololearn.com/WpmOUztWdoW9/?ref=app
+ 3
Thanks a lot Russ for helping me. This solution works absolutely correctly.
Suggestion for the hopeless visitors: please don't downvote an answer if you don't understand it; verify its validity and then respond, because no one has requested your useless response!
0
No worries. Glad I could help. Nice code btw!