微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – 将复选框(多个选项)转换为单选按钮或复选框?

我有以下复选框列表.输出列表的方式允许用户选择多个值.但是,我只需要允许用户从下面的复选框列表中选择一个值.

有可能用jQuery以某种方式实现这一点吗?将列表更改为单选按钮,选择列表或其他可能有用的内容也是可以的.

不幸的是我无法访问生成函数,所以我无法更改输出.

提前致谢

Box" class="form-checkBox" value="1" id="edit-notifications-custom-custom-berlin" name="notifications_custom[custom_berlin]"> BerlinBox" class="form-checkBox" value="1" id="edit-notifications-custom-custom-hamburg" name="notifications_custom[custom_hamburg]"> HamburgBox" class="form-checkBox" value="1" id="edit-notifications-custom-custom-frankfurt-am-main" name="notifications_custom[custom_frankfurt-am-main]"> Frankfurt am MainBox" class="form-checkBox" value="1" id="edit-notifications-custom-custom-duesseldorf" name="notifications_custom[custom_duesseldorf]"> DüsseldorfBox" class="form-checkBox" value="1" id="edit-notifications-custom-custom-bielefeld" name="notifications_custom[custom_bielefeld]"> BielefeldBox" class="form-checkBox" value="1" id="edit-notifications-custom-custom-muenchen" name="notifications_custom[custom_muenchen]"> München

asdasd

最佳答案
$('.form-checkBox').bind('click',function() {
    $('.form-checkBox').not(this).attr('checked',false);
});

已编辑以优化性能.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐