解决方法
在许多可能的方法中,这种方法需要浏览器嗅探(通常不是很好),但不需要具有相同选择列表的多个副本来交换.
//To hide elements $("select option").each(function(index,val){ if ($(this).is('option') && (!$(this).parent().is('span'))) $(this).wrap((navigator.appName == 'Microsoft Internet Explorer') ? '<span>' : null).hide(); }); //To show elements $("select option").each(function(index,val) { if(navigator.appName == 'Microsoft Internet Explorer') { if (this.nodeName.toUpperCase() === 'OPTION') { var span = $(this).parent(); var opt = this; if($(this).parent().is('span')) { $(opt).show(); $(span).replaceWith(opt); } } } else { $(this).show(); //all other browsers use standard .show() } });
对此的信任与Dima Svirid完全吻合:http://ajax911.com/hide-options-selecbox-jquery/