+ 1
Help
How to make a <input type=âradioâ /> button be able to unclick
3 Answers
+ 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.
+ 1
thx guys i got it
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. :)