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?
You have to implement two methods for hiding.
display: noneworks for FF, but not Chrome or IE. So the second method is wrapping the<option>in a<span>withdisplay: none. FF won’t do it (technically invalid HTML, per the spec) but Chrome and IE will and it will hide the option.EDIT: Oh yeah, I already implemented this in jQuery:
EDIT 2: Here’s how you would use this function:
EDIT 3: Added extra check suggested by @user1521986