I\'m trying to hide a few options in a dropdown box using .hide(). This works perfectly fine in firefox and chrome, but it doesn\'t work in IE and Safari. My original code i
I tried the solution that uses around options, but found that it didn't work for me in all browsers.
I've made a jQuery Plugin that solves this very nicely. With it, you would do this:
$('#selection1').hideOption('1');
$('#selection1').showOption('1');
You can hide and show them as much as you want, and they will keep their original order and any .data('x') values you've assigned to the option. It works in all browsers. You can see that in this sample: jsFiddle - Toggle Dropdown Options
You can get the Toggle Dropdown Options plug-in. If you don't like plug-ins, just copy the JavaScript code from it to your own project's JavaScript file. See the Read the Docs link on the plug-in for more information!