Làm cách nào để bật lạiChay tất cả giá trị đã chọn trong menu thả xuống nhiều lựa chọn của tôi. Đã sử dụng plugin here. Cố gắng sử dụng những điều sau đây nhưng tôi nghĩ rằng tôi đang trên đường đua saibootstrap multiselect nhận giá trị đã chọn
$('#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);
}
});
tìm thấy nó
$('#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);
}
});
+1 cho giải pháp tuy nhiên bạn đã gặp lỗi trong câu lệnh đã chọn. bạn đang đẩy danh sách giá trị tùy chọn thay vì giá trị dưới dạng chuỗi. bạn muốn xóa các dấu ngoặc kèm theo. – tbradley22