Furtiro Furtiro - 5 months ago 53x
jQuery Question

HTML select picker multiple , options "all" disable all other options

I have a select picker element like this in my web page :

<select id="difficulty" name="difficulty" class="selectpicker" multiple onchange="ChangeFilters()">
<option value="-1" selected >All</option>
<option value="0" >Facile</option>
<option value="1" >Normal</option>
<option value="2" >Difficile</option>

I want that when the user select the "All" options (value = '-1') , if there are other options selected they become not selected, and if the option all is selected when the user select an other options the "all option" become not selected.

I have searched for like 2 hours and i can't make this working.

I work with bootstrap and this select element is a selectpicker element, my javascript don't work when i try something ..

Please help !


Something like this?

        function ChangeFilters(){
            var selVal = $('#difficulty').val()[0];

            if(selVal == -1){