【发布时间】:2015-02-03 15:07:54
【问题描述】:
是否可以有 2 组共享一个 ID 的单选按钮?我似乎无法让他们好好相处。
演示:http://abenjamin765.github.io/slidemenu/
<input type="radio" name="set-one" id="radio-one">
<input type="radio" name="set-one" id="radio-two">
<input type="radio" name="set-one" id="radio-three">
<input type="radio" name="set-two" id="radio-one">
<input type="radio" name="set-two" id="radio-two">
<input type="radio" name="set-two" id="radio-three">
干杯!
【问题讨论】:
-
ID 必须是唯一的。
-
现在:也许您可以解释为什么您希望元素共享一个唯一标识符?我怀疑你试图解决的问题比这条路线更容易解决。
-
ID 必须是唯一的。如果需要,请尝试为它们分配相同的类,并为该类对输入执行操作。
-
我将单选按钮用作导航栏中的选项卡,而不是单选选项。它需要足够灵活,以便在页面上多次出现而不会发生冲突。