Chauhan Khalid
Chauhan Khalid

Reputation: 187

Want to enable only first option in dropdown and disable other options

I have a drop down, in that I have first option "Select All" and other options. So if I select "Select All", I want to disable all other options, but as soon as I remove "Select All" option then all other options should be selectable.

Upvotes: 0

Views: 51

Answers (1)

Ashish Balchandani
Ashish Balchandani

Reputation: 1266

you need this code

$('#mydropdwon').change(function(){
if($('#mydropdwon').val() == "Select All"){

        $(".myoptins").not($(".all")).prop('disabled', function(i, a) { return !a; });
    }
});

Working solution here

Please let me know if it helps.

But I would recommend you to have move select All out of drop down, you can enable/disable dropdown based on that checkbox, just for intuitiveness.

Upvotes: 3

Related Questions