728x90
반응형
✅ 방법: 전체 선택 후 특정 항목 제외
// 전체 선택
$('#mySelect').multiselect('selectAll', false);
$('#mySelect').multiselect('updateButtonText');
// 특정 value를 제외 (예: 'exceptMe' 라는 값을 가진 항목)
$('#mySelect').multiselect('deselect', 'exceptMe');
🔁 여러 개 제외하고 싶다면?
const exceptValues = ['val1', 'val2'];
$('#mySelect').multiselect('selectAll', false);
$('#mySelect').multiselect('updateButtonText');
exceptValues.forEach(value => {
$('#mySelect').multiselect('deselect', value);
});
✅ 대체 방식: 처음부터 선택할 항목만 골라서 설정
const allValues = $('#mySelect option').map(function() {
return $(this).val();
}).get();
const exceptValues = ['val1', 'val2'];
const selectedValues = allValues.filter(v => !exceptValues.includes(v));
$('#mySelect').multiselect('select', selectedValues);
$('#mySelect').multiselect('updateButtonText');
728x90
반응형
'Front > JS & jQuery' 카테고리의 다른 글
[js] return, return false (0) | 2025.04.05 |
---|---|
[jQuery] .multiselect('selectAll', false); false 가 전체선택임? (0) | 2025.04.04 |
[jQuery] Multiselect Plugin selectAll (전체선택) (0) | 2025.04.02 |
[js] closest() 주의사항 - name 속성 보다는 id나 class 사용하기 (0) | 2025.03.30 |
[js] moment().format() 와 moment().toDate() 의 차이 (0) | 2025.03.29 |