I need to disable a select option based on the value of a variable. The value is similar to one of the select option value and it needs to be disabled.
For ex,
Let's say you had the following markup
Volvo Saab Mercedes Audi
Using this jQuery, the saab option would be disabled.
$("select option").each(function() { var $thisOption = $(this); var valueToCompare = "saab"; if($thisOption.val() == valueToCompare) { $thisOption.attr("disabled", "disabled"); } });
Try it out here