Reputation: 1613
Is there a reliable way (CSS, JQuery, etc.) to completely hide a disabled
<option disabled="disabled">
on all major browsers?
I need it to be completely hidden instead of being only greyed out (like in IE).
UPDATE: There is no crossbrowser way of hiding disabled options. If you need an option removed, use Jquery's detach() as pointed out below by Kevin B. disabled options are no good thing.
Upvotes: 0
Views: 402
Reputation: 95026
Yes, remove it from the select until you want to show it.
var options = $("#myselect option");
// to disable the option at index 3
options.eq(3).detach();
// to enable the option at index 3
options.eq(3).insertAfter(options.eq(2)); // assuming option at index 2 is still attached to the DOM
Upvotes: 2