gpt4 book ai didi

jquery - bootstrap 多选获取选定值

转载 作者:行者123 更新时间:2023-12-03 21:32:43 24 4
gpt4 key购买 nike

如何返回 onChange 多选下拉列表中的所有选定值。使用过的插件here 。尝试使用以下内容,但我认为我走错了路

$('#multiselect1').multiselect({
selectAllValue: 'multiselect-all',
enableCaseInsensitiveFiltering: true,
enableFiltering: true,
maxHeight: '300',
buttonWidth: '235',
onChange: function(element, checked) {
var brands = $('#multiselect1 option:selected');
var selection = [];
$(brands).each(function(index, brand){
selection.push(brand);
});

console.log(selection);
}
});

找到了

$('#multiselect1').multiselect({
selectAllValue: 'multiselect-all',
enableCaseInsensitiveFiltering: true,
enableFiltering: true,
maxHeight: '300',
buttonWidth: '235',
onChange: function(element, checked) {
var brands = $('#multiselect1 option:selected');
var selected = [];
$(brands).each(function(index, brand){
selected.push([$(this).val()]);
});

console.log(selected);
}
});

最佳答案

我发现适用于我的案例的解决方案

$('#multiselect1').multiselect({
selectAllValue: 'multiselect-all',
enableCaseInsensitiveFiltering: true,
enableFiltering: true,
maxHeight: '300',
buttonWidth: '235',
onChange: function(element, checked) {
var brands = $('#multiselect1 option:selected');
var selected = [];
$(brands).each(function(index, brand){
selected.push([$(this).val()]);
});

console.log(selected);
}
});

关于jquery - bootstrap 多选获取选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20516166/

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