gpt4 book ai didi

multi-select - 选择实现多选中的所有选项

转载 作者:行者123 更新时间:2023-12-02 15:10:50 26 4
gpt4 key购买 nike

Bootstrap multisleect 具有全选选项 ( for example here )。这可能实现多选吗?

最佳答案

这是一个较小的版本:https://codepen.io/souvik1809/pen/rvNMyO

HTML

<div class = "row">
<label>Materialize Multi Select</label>
<select multiple class="select_all">
<option value="" disabled selected>Choose your option</option>
<option value = "1">Mango</option>
<option value = "24">Orange</option>
<option value = "3">Apple</option>
<option value = "4">Cucumber</option>
<option value = "5">Litchi</option>
</select>
</div>

JavaScript

$(document).ready(function() {
// $('select').val([1]);
$('select').formSelect();
$('select.select_all').siblings('ul').prepend('<li id=sm_select_all><span>Select All</span></li>');
$('li#sm_select_all').on('click', function () {
var jq_elem = $(this),
jq_elem_span = jq_elem.find('span'),
select_all = jq_elem_span.text() == 'Select All',
set_text = select_all ? 'Select None' : 'Select All';
jq_elem_span.text(set_text);
jq_elem.siblings('li').filter(function() {
return $(this).find('input').prop('checked') != select_all;
}).click();
});
});

关于multi-select - 选择实现多选中的所有选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44001532/

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