IE select option disabled fix using jquery

I spent a good couple hours fighting with IE and finally found a solution to fix the disabled option issue. Hope it helps you out.

1
2
3
4
5
6
7
8
9
10
11
12
13
ieLessThan8OptionDisable = function() {
    if ($.browser.msie && parseFloat($.browser.version) < 8) {
        $("select").find("[disabled]").addClass("disabled").removeAttr("disabled");
        $("select").change(function(){
            var selected = $(this).val();
            var disabled = $(this).find("[value="+selected+"]").hasClass("disabled");
            if (disabled) {
                alert("This option is disabled.\nSelect will be set to the first option.");
                $(this).find("option:first").attr("selected","selected");
            }
        });
    }
}

Tags: , , , , ,

One comment

Leave a comment

You must be logged in to post a comment.