Help | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Help

How to make a <input type=“radio” /> button be able to unclick

16th Jun 2018, 2:47 AM
Stef
Stef - avatar
3 ответов
+ 2
I kept finding articles saying this can't be done, so I made one: https://code.sololearn.com/WBFDfvTGTeAs/?ref=app There might be a better way. I didn't find one. Event info: change() only fires on click when it's unchecked (they're not designed to be erasable like this). change() fires first, so "checked=true" is always set when click() fires Either it was true already, or change() just set it true. Since click() cannot tell the difference between "just set" and "already set", I keep a record that change() just fired -- for 50ms -- ok for the code / unlikely people will be toggling that fast.
16th Jun 2018, 5:03 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
thx guys i got it
18th Jun 2018, 1:13 AM
Stef
Stef - avatar
0
Hmmm... Can I ask why you want the radio to be unchecked? Maybe an example would help. Otherwise, I suspect that Kirk and I would spend quite a bit of effort stabbing in the dark. :)
16th Jun 2018, 11:28 PM
Janning
Janning - avatar