'select all' and 'remove all' with chosen.js

前端 未结 7 1705
深忆病人
深忆病人 2020-12-24 12:29

For the select menu plugin chosen.js, is there an established way to add \'select all items in list\' or \'remove all items in list\' feature to a multiple select input? In

7条回答
  •  孤独总比滥情好
    2020-12-24 13:15

    Try this code it will work 100%

    // Deselect All
    $('#my_select_box option:selected').removeAttr('selected');
    $('#my_select_box').trigger('chosen:updated');
    
    // Select All
    $('#my_select_box option').prop('selected', true);  
    $('#my_select_box').trigger('chosen:updated');
    

提交回复
热议问题