how to disable select option in html code example

Example 1: html non selectable option

<option disabled selected value> -- select an option -- </option>

Example 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>

Example 3: howt to disable a select tag using js

document.getElementById("one").onchange = function () {
  document.getElementById("two").setAttribute("disabled", "disabled");
  if (this.value == 'car')
    document.getElementById("two").removeAttribute("disabled");
};

Example 4: html select option disabled selected

<option selected disabled>Choose Tagging</option>

Tags:

Html Example