Options with display:none not hidden in IE

后端 未结 10 1020
梦如初夏
梦如初夏 2020-11-27 17:41

I have multiple options in a select. I have sorted the options and disabled and hidden the duplicate options with jquery. The code works well in chrome and firefox but in IE

10条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 18:42

    Expanding on Zhangjiang Huang's answer: Pretty much you cache all the options, detach them from the drop-down, then you reattach the ones you want.

    JQuery:

    (function(){
       // Cache List
       var options = $("select option");
    
       // Clear list
       options.detach();
       // Rebuild list
       options.not(".disabled").appendTo("select");
       // Set Default
       $("select").val("");
    })();
    

    HTML:

    
    

    jsfiddle

提交回复
热议问题