Sky*_*ker 2 html javascript checkbox twitter-bootstrap
我的应用程序中有一个数据过滤功能,用户可以在其中使用复选框和下拉列表来选择他们希望如何过滤数据。
我正在使用引导程序复选框:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="checkbox" autocomplete="off" checked> Checkbox 1 (pre-checked)
</label>
<label class="btn btn-primary">
<input type="checkbox" autocomplete="off"> Checkbox 2
</label>
<label class="btn btn-primary">
<input type="checkbox" autocomplete="off"> Checkbox 3
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
我有一个清除过滤器按钮,它清除过滤器中的所有用户输入,重置所有复选框,所有下拉菜单,所有文本字段。
我能够像这样重置下拉菜单:
// sectorPicker is drop down
document.getElementById('sectorPicker').reset();
Run Code Online (Sandbox Code Playgroud)
下面是我的复选框的图像:
但我无法弄清楚如何重置屏幕上的 Bootstrap 复选框以取消选中所有复选框。
有什么想法吗?
这将从其父标签中删除选中的属性和活动类
$(":checkbox").prop('checked', false).parent().removeClass('active');
Run Code Online (Sandbox Code Playgroud)