Ideally, you simply remove the selected attribute from the disabled options on the server side when creating the HTML document to begin with.
Otherwise, if you use jQuery, this can be done quite easily with:
$('#Category').find('option:not([disabled])').first().prop('selected', true);
Add this to the ondomready event ondomready . This will cause the first parameter to be selected for this select element without disabling, regardless of its selected attributes. The disadvantage of this method is that it will prevent the use of the selected attribute in general with this select element.
On the other hand, if you are trying to create category headings in a select element, you should use the optgroup element optgroup , as this is the correct semantic markup for this:
<select id="Category" name="Category"> <optgroup label="Category"> <option value="1">General Info</option> <option value="2">Booking</option> <option value="3">Auditions</option> </optgroup> </select>
source share