I've realized that Chrome, it seems, will not allow me to hide <option>
in a <select>
. Firefox will.
I need to hide the <option>
s that match a search criteria. In the Chrome web tools I can see that they are correctly being set to display: none;
by my JavaScript, but once then <select>
menu is clicked they are shown.
How can I make these <option>
s that match my search criteria NOT show when the menu is clicked? Thanks!
Since you're already using JS, you could create a hidden SELECT element on the page, and for each item you are trying to hide in that list, move it to the hidden list. This way, they can be easily restored.
I don't know a way offhand of doing it in pure CSS... I would have thought that the display:none trick would have worked.
You should remove them from the
<select>
using JavaScript. That is the only guaranteed way to make them go away.Ryan P's answer should be changed to:
Otherwise it gets wrapped in too many tags
The toggleOption function is not perfect and introduced nasty bugs in my application. jQuery will get confused with .val() and .arraySerialize() Try to select options 4 and 5 to see what I mean:
Late to the game, but most of these seem quite complicated.
Here's how I did it:
markup of select-1:
markup of select-2: