Answers for "select option with disable"

2

html option disabled

<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="n/a" disabled>unavailable</option>
</select> 
<select name="color" id="color">
	<option value="" selected disabled hidden>Choose color...</option>
    <option value="R">Red</option>
    <option value="B">Blue</option>
</select>
Posted by: Guest on March-20-2021
0

chosen-select disable

$('#foobar').prop('disabled', true).trigger("chosen:updated");
Posted by: Guest on May-29-2020
0

disable other options in select except the selected

$("#lbCountries").click(function () {
     $("#lbCountires option").each(function (index) {
        if ($(this).is(':selected')) {
            $(this).prop('disabled', false);
         }
         else {
            $(this).prop('disabled', true);
         }
      });
  });
Posted by: Guest on December-23-2020

Code answers related to "select option with disable"

Browse Popular Code Answers by Language