我正在使用Bootstrap Switch进行Twitter Bootstrap.在这里,我有问题检查或取消选中基于全局复选框选中或取消选中的所有复选框
这是bootstrap交换机链接http://www.bootstrap-switch.org/
这就是我所做的
<!-- this is the global checkbox -->
<div class="make-switch switch-mini">
<input type="checkbox" id="rowSelectAll">
</div>
<!-- row checkboxs -->
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$("#rowSelectAll").click(function () {
$(".row-select").prop('checked', $(this).prop('checked'));
});
Run Code Online (Sandbox Code Playgroud)
编辑:尝试只有一个全局和一个本地复选框
<div class="make-switch switch-mini">
<input type="checkbox" id="rowSelectAll">
</div>
<div id="toggle-state-switch" class="make-switch switch-mini row-select">
<input type="checkbox" class="">
</div>
Run Code Online (Sandbox Code Playgroud) $(document).ready(function(){
function set_checked {
alert('test');
$('*:checkbox').attr('checked', checked);
}
});
Run Code Online (Sandbox Code Playgroud)
还有这个html
<input onclick="set_checked()" value="Check all" type="button" />
Run Code Online (Sandbox Code Playgroud)
由于某种原因不起作用。没有警报框或什么都没有。