开发者

How to clear all radio buttons using right click in Javascript?

开发者 https://www.devze.com 2022-12-26 20:19 出处:网络
I would like to clear all radio buttons in a group开发者_高级运维 if I right click on one of them.

I would like to clear all radio buttons in a group开发者_高级运维 if I right click on one of them. How can I implement this using Javascript ?


Rather than

Right click an option to deselect:

(*) option 1
( ) option 2
( ) option 3

which is abusing the user interface, you're better to do this:

( ) none
(*) option 1
( ) option 2
( ) option 3


Conceptually you can't unselect radio buttons. The point of a radio button group is that at least one needs to be selected. It could actually be considered a bug that it's possible to have a radio button group in which no item is selected.

I suppose you'd have to remove and re-generate the group to clear the selection, exploiting this "bug".


Check out this link at quirksmode on capturing the right mouse click. The combination of an element and a right click should let you uncheck all radio buttons in a given group.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号