jQuery dropdownlist select all - maikelbos0/VDT GitHub Wiki

When creating a multiselect dropdownlist, sometimes you want to include an option to select/deselect all items. To achieve this, add an element to your dropdownlist with the data-select-all attribute added. For this element a checkbox will also be added, but this checkbox will not have the field name set, nor affect the selected items when interacting with the dropdownlist client-side. The location of the select all item does not matter, as long as it is inside the dropdownlist.

<div id="example-dropdown" data-multiselect="true">
    <div data-select-all="true">Select all options</div>
    <div>Choice number 1</div>
    <div>Option 1a</div>
    <div>Second choice</div>
    <div>Final option</div>
</div>

<script type="text/javascript">
    $('#example-dropdown').dropdownlist();
</script>
⚠️ **GitHub.com Fallback** ⚠️