jQuery('#by option:eq(2)').hide();
this is not working in ie. Here by is the id of select element.
Asked
Active
Viewed 681 times
0

sushil bharwani
- 29,685
- 30
- 94
- 128
-
1http://stackoverflow.com/questions/2031740/hide-select-option-in-ie-using-jquery – Andy Aug 25 '11 at 12:12
-
what does the 2 here refer to? – Baz1nga Aug 25 '11 at 12:45
1 Answers
1
The problem in IE is not with the selector but with hiding the option as unfortunately this method is not available in IE.
There are two workarounds that you may try to accommodate for the absence of this feature:
- Use the
detach()
function within jquery and utilize and add the option back using theappend()
function. - Add the
disabled
attribute on the option:disabled="disabled"
.
I have shown both here: Live Demo

Baz1nga
- 15,485
- 3
- 35
- 61
-
This code does not works in ie. Please see the question that its not working in ie. – sushil bharwani Aug 25 '11 at 14:26
-
I could still select a disabled element in IE. In chrome although its working fine. The detach works fine in ie. How would i attach back the element? – sushil bharwani Aug 26 '11 at 05:41
-
use the append api... $("select").append(html); the html in this case should be backed up by you in a temporary variable perhaps before detaching from the dom – Baz1nga Aug 26 '11 at 09:08