tags:

views:

34

answers:

1

Hi, I have a select lists, which has lots of option. Depending on some input I want to hide few options from select list. To hide options from select list I have written jquery like

$('#selectlist1 option').each(function(){  

   $(this).hide();

})

But this code seems to work only for firefox and its not working on chrome and ie. Whereas if I write

$('#selectlist1').hide();

it works for all browser. Any pointer where should I look at?

+1  A: 

You cannot hide individual option elements x-browser. The only solution is to replace the select with a new element with only the options you wish to display.

See this other question

redsquare
What do you mean by 'x-browser'? I tried the solution suggested by you. the problem is that I am using drupal and it store some data in cache to verify form structure. So if I remove some element and add them later, it gives error during validation.So i thought using show/hide method of jquery I can do that without any validation error. But it seems this is not supported in any browser other than mozilla.
ninja
x-browser = cross browser (chrome, ff, ie opera etc)
redsquare