我想知道您是否可以制作一个按钮,其功能类似于 HTML 单选按钮。我正在尝试创建一个表单,用户在该表单中单击所述按钮并因此选择一个值,但在选择另一个选项并提交表单之前不会指导用户。有谁知道该怎么做?
(我不介意使用其他语言包括javascript等)
最佳答案
jQueryUI has a Button Widget将单选按钮或复选框转换为按钮。
网站示例:
http://jqueryui.com/demos/button/#radio
<script>
$(function() {
$( "#radio" ).buttonset();
});
</script>
<div class="demo">
<form>
<div id="radio">
<input type="radio" id="radio1" name="radio" /><label for="radio1">Choice 1</label>
<input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Choice 2</label>
<input type="radio" id="radio3" name="radio" /><label for="radio3">Choice 3</label>
</div>
</form>
</div>
您可以访问该链接以查看它的运行情况。
关于javascript - 具有单选按钮功能的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841725/