ドル('option').hide()does not work in IE and chrome,FF works.

800 ワード

here's is a workound in IE and chrome.
The idea is to wrap the option with aand hide that
 
function optWrapper(opt){
    var optSpan = undefined;
    if ($(opt).parent().is('span')){
        optSpan = $(opt).parent();
    }
    return optSpan;
}
 
function hideOption(opt){
    var wrapper = optWrapper(opt);
    if (wrapper === undefined){
        $(opt).wrap('<span>').hide();
    }else{
        $(wrapper).hide();
    }
}

function showOption(opt){
    var wrapper = optWrapper(opt);
    $(opt).show();
    if (wrapper !== undefined){
        $(wrapper).replaceWith(opt);
    }      
}