如何同时选中一组的两个单选按钮?
How to have two radio buttons of one group checked at the same time?
我有一个定价 table,我将单选按钮放在 table 的顶部和底部。
无论用户点击顶部还是底部的单选按钮,我都希望同时选中两个单选按钮。
<input type="radio" name="group1">If you check me...<br>
<input type="radio" name="group1">...I also want to be checked
<br><br>
<input type="radio" name="group2">If you check me...<br>
<input type="radio" name="group2">...I also want to be checked
<br><br><br> Just a pic of a cat
<br>
<img src="https://s-media-cache-ak0.pinimg.com/736x/07/c3/45/07c345d0eca11d0bc97c894751ba1b46.jpg" />
单选按钮不是这样工作的。一组中一次只能 select 个。
您应该改用复选框。
4.10.5.1.13 Radio Button state
(type=radio
)
The input
element represents a control that, when used in
conjunction with other input
elements, forms a radio button group
in which only one control can have its checkedness state set to true.
是的,改用复选框并增加边框半径,让它们看起来像一个收音机
<input type="radio" name="group1">If you check me...<br>
<input type="radio" name="group1">...I also want to be checked
<br><br>
<input type="radio" name="group2">If you check me...<br>
<input type="radio" name="group2">...I also want to be checked
<br><br><br> Just a pic of a cat
<br>
<img src="https://s-media-cache-ak0.pinimg.com/736x/07/c3/45/07c345d0eca11d0bc97c894751ba1b46.jpg" />
我有一个定价 table,我将单选按钮放在 table 的顶部和底部。
无论用户点击顶部还是底部的单选按钮,我都希望同时选中两个单选按钮。
<input type="radio" name="group1">If you check me...<br>
<input type="radio" name="group1">...I also want to be checked
<br><br>
<input type="radio" name="group2">If you check me...<br>
<input type="radio" name="group2">...I also want to be checked
<br><br><br> Just a pic of a cat
<br>
<img src="https://s-media-cache-ak0.pinimg.com/736x/07/c3/45/07c345d0eca11d0bc97c894751ba1b46.jpg" />
单选按钮不是这样工作的。一组中一次只能 select 个。
您应该改用复选框。
4.10.5.1.13 Radio Button state (
type=radio
)The
input
element represents a control that, when used in conjunction with otherinput
elements, forms a radio button group in which only one control can have its checkedness state set to true.
是的,改用复选框并增加边框半径,让它们看起来像一个收音机
<input type="radio" name="group1">If you check me...<br>
<input type="radio" name="group1">...I also want to be checked
<br><br>
<input type="radio" name="group2">If you check me...<br>
<input type="radio" name="group2">...I also want to be checked
<br><br><br> Just a pic of a cat
<br>
<img src="https://s-media-cache-ak0.pinimg.com/736x/07/c3/45/07c345d0eca11d0bc97c894751ba1b46.jpg" />