How can I disable an option in a select box based on its value in JavaScript?

Without enabling non-targeted elements:

jQuery

With jQuery you can do this with a single line:

Without enabling non-targeted elements:

Note that this is not case insensitive. “optionvalue” will not equal “optionvalue”. To get a case-insensitive match, you’d have to cycle through each, converting the value to a lower case, and then check against that:

Without enabling non-targeted elements: