views:

1339

answers:

4

Currently I am using jQuery to hide/show select options using following code.

$("#custcol7 option[value=" + sizeValue + "]").hide();

This works fine in Firefox, but doesnt do any good in other browsers. How to I hide options from select in Chrome, Opera and IE?

+2  A: 

You don't, it's not supported in IE (and assumably not in Chrome or Opera either). You would have to remove the options altogether and add them back later if you want them to be truly invisible. But in most cases a simple disabled="disabled" should suffice and is a heck of a lot simpler than handling the removing and adding of options.

Tatu Ulmanen
IIRC, you can't disable options in IE6 or IE7 (was fixed in IE8) http://webbugtrack.blogspot.com/2007/11/bug-293-cant-disable-options-in-ie.html
scunliffe
Duuummbbb!!! I hate IE with a passion. They can't get anything right!! Freaking text and password boxes aren't even the same width by default for no apparent reason!? Rounded corners don't work? Nothing lines up properly... I don't get it !!
Mark
+2  A: 

Just deleted it and store it in a var in your JavaScript. You can just create the new object when you need it later.

Otherwise try the disabled attribute mentioned above.

Joseph Silvashy
+1  A: 

try detach(). you can reattach it later if needed using append() or insertAfter()

murraybiscuit