JS option in select disabled on value?

How can I use JS to disable option on value not option index.

<select id="myselect">
 <option value="20">20</option>
 <option value="30">30</option>
</select>

document.getElementById('myselect').options[0].disabled = true;
document.getElementById('myselect').options[1].disabled = false;

17 thoughts on “JS option in select disabled on value?”

Leave a Comment