<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
标签 javascript html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
我正在尝试制作一个三向切换,类似于 this , 但分 3 个阶段。显然这不能使用复选框来完成,因为这是一个 bool 值,所以我想知道是否可以使用 3 个单选按钮来模拟这样的事情?这样的事情可能吗?如果是这样,这是解决这个问题的正确方法吗?
顺便说一句,Javascript 很好。
最佳答案
注意:因为这已经被否决了,我想我要指出我在 javascript 之前发布了这个答案。已添加到问题中,因此请将其视为纯 HTML 解决方案,仅此而已。
单选按钮正是您执行此操作的方式:
<label>State 1
<input type="radio" name="radios" value="State 1" />
</label>
<label>State 2
<input type="radio" name="radios" value="State 2" />
</label>
<label>State 3
<input type="radio" name="radios" value="State 3" />
</label>
这样你就有了 3 个状态。在上面的答案中,结果是状态 1、状态 2 或状态 3。
关于javascript - 是否可以进行 3 向切换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27818559/