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
This will work.. change .show to .showOption and .hideOption. However this still kind of sucks in IE because in firefox you can make it hide an option which is selected. So if "Select One" is shown and is hidden. Firefox will still say "select one".
$.fn.showOption = function() {
this.each(function() {
if( this.tagName == "OPTION" ) {
var opt = this;
if( $(this).parent().get(0).tagName == "SPAN" ) {
var span = $(this).parent().get(0);
$(span).replaceWith(opt);
$(span).remove();
}
opt.disabled = false;
$(opt).show();
}
});
return this;
}
$.fn.hideOption = function() {
this.each(function() {
if( this.tagName == "OPTION" ) {
var opt = this;
if( $(this).parent().get(0).tagName == "SPAN" ) {
var span = $(this).parent().get(0);
$(span).hide();
} else {
$(opt).wrap("span").hide();
}
opt.disabled = true;
}
});
return this;
}