取消选择所有选项
如果你指的是更新用户界面,你可以明确地从所有的按钮(或在您的案件标签)删除active
类本身:
$('#Reset').click(function(){
// Explicitly uncheck all of your radio buttons
$('[data-toggle="buttons"] :radio').prop('checked', false);
// Select all label elements within your toggle and remove the active class
$('[data-toggle="buttons"] label').removeClass('active');
});
您可以see this in action here和演示如下:
设到第一个选项
同样的,如果你想将其设置为它的初始选项,你可以简单地触发第一元素的click
事件:
$('#Reset').click(function(){
// Explicitly uncheck all of your radio buttons
$('[data-toggle="buttons"] :radio').prop('checked', false);
// Select all label elements within your toggle and remove the active class
$('[data-toggle="buttons"] label').removeClass('active');
// Set the first one as checked and selected
$('[data-toggle="buttons"] :radio:first').addClass('active');
// Do the same thing for the active indicator
$('[data-toggle="buttons"] label:first').addClass('active');
});
可以see this option in action here和证明如下:
我假设上点击复位要恢复预选即#选项1,应再次选择。 – sahil