gpt4 book ai didi

jquery - Bootstrap Switch,全局复选框(取消选中所有其他

转载 作者:行者123 更新时间:2023-12-03 22:26:40 28 4
gpt4 key购买 nike

我正在使用 Twitter Bootstrap 的 Bootstrap Switch。在这里,我无法根据选中或未选中的全局复选框来选中或取消选中所有复选框

这里是 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>

jQuery:

$("#rowSelectAll").click(function () {
$(".row-select").prop('checked', $(this).prop('checked'));
});

编辑:仅尝试使用一个全局复选框和一个本地复选框

<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>

最佳答案

试试这个,应该有效。另请参阅此 jsfiddle... http://jsfiddle.net/URAcy/5/

  <!-- this is the global checkbox -->
<div class="make-switch switch-mini" id="rowSelectAll">
<input type="checkbox" id="rowSelectAllc">
</div>

<!-- row checkboxs -->
<div class="make-switch switch-mini toggle-state-switch">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini toggle-state-switch">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini toggle-state-switch">
<input type="checkbox" class="row-select">
</div>

JS:

$('#rowSelectAll').on('switch-change', function (e, data) {
var $el = $(data.el)
, value = data.value;
$('.toggle-state-switch').each(function( index ) {
$(this).bootstrapSwitch('setState' , value);
});
});

关于jquery - Bootstrap Switch,全局复选框(取消选中所有其他,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18911067/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com