MultiSelect : Object expected. Jquery does not work in IE. Works well in Firefox
<p>The following Jquery code works well in Firefox but throws exception in IE. Please help. The following code will render a multi select box where you can drag and drop values from one box to other. The code when run in IE throws an object expected expception. As it in inside a large page, the actual place of bug can not be identified.</p>

<pre><code>$(document).ready(function() {

    //adding combo box
    $(".combo").each(function() {

        var name = "to" + $(this).attr('name');
        var $sel = $("&lt;select&gt;").addClass("multi_select");
        $sel.addClass("combo2");
        $sel.attr('id', $(this).attr('id') + "_rec");
        $(this).after($sel);
    });

    $(".multi_select").hide();

    var $tab;
    var i = 0;
    var temp = 0;
    //creating different div's to accomodate different elements
    $(".multi_select").each(function() {
        var $cont = $("#container");
        var $input;
        if ($(this).hasClass("combo") || $(this).hasClass("combo2")) {

            var $col = null;
            if ($(this).hasClass("combo")) {
                $tab = $("&lt;table&gt;");
                $cont = ($tab).appendTo($cont);
                var idT = $(this).attr('id');
                var $row = $("&lt;tr id='" + idT + "_row1'&gt;").appendTo($tab);
                $col = $("&lt;td id='" + idT + "_col1'&gt;").appendTo($row);
                $input = $("&lt;input class='searchOpt'&gt;&lt;/input&gt;&lt;img src='images/add.png' class='arrow1'/&gt; ");
                $("&lt;div&gt;").addClass('ip_outer_container combo').attr('id', $(this).attr('id') + "out_div").append("&lt;h3 class='header_select'&gt;Tasks&lt;/h3&gt;").appendTo($col);
                ($row).after("&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;textarea name='" + $(this).attr("name") + "Text' id='" + $(this).attr("id") + "Text'&gt;&lt;/textarea&gt; &lt;/td&gt;&lt;/tr&gt;");

                $cont = $tab;
            } else {
                var idTm = $(this).attr('id');
                var $row2 = $("&lt;tr id='" + idTm + "_row2'&gt;").appendTo($tab);
                var $col2 = $("&lt;td id='" + idTm + "_col2'&gt;").appendTo($row2);
                $input = $("&lt;input class='searchOpt'&gt;&lt;/input&gt;");

                $("&lt;div&gt;").addClass('ip_outer_container combo2').attr('id', $(this).attr('id') + "out_div").append("&lt;h3 class='header_select'&gt;Tasks&lt;/h3&gt;").appendTo($col2);

            }


        } else {
            $("&lt;div&gt;").addClass('ip_outer_container' + classSelect).attr('id', $(this).attr('id') + "out_div").append("&lt;h3 class='header_select'&gt;Tasks&lt;/h3&gt;").appendTo($cont);
        }

        $("&lt;div&gt;").addClass('outer_container').attr('id', $(this).attr('id') + "_div").appendTo('#' + $(this).attr('id') + "out_div");
        $($input).appendTo("#" + $(this).attr('id') + "out_div");

    });

    //adding options from select box to accomodate different //elements
    $(".multi_select option").each(function() {
        $(this).attr('id', $(this).parent().attr('id') + "option_" + i);

        var val = $(this).val().replace("#comment#", "");
        var $d = $("&lt;div class='multi_select_div'&gt;" + val + "&lt;/div&gt;").attr('id', $(this).parent().attr('id') + 'option_div_' + i);
        $d.appendTo("#" + $(this).parent().attr('id') + "_div");
        i++;
    });

    //delete function
    $(".delete").click(function() {
        $(this).parent().remove();
    });
    //input
    $(".searchOpt").keyup(function() {
        $(this).prev().children().show();
        var val = $(this).val();
        if (val != "") {
            var selId = $(this).prev().attr('id');
            selId = selId.replace("_div", "option_div");
            $(this).prev().children().not("div[id^=" + selId + "]:contains(" + val + ")").hide();
            //var $d=$('div[id^="multi_select_senoption_div"]');
            //$('div[id^="multi_select_senoption_div"]').not('div[id^="multi_select_senoption_div"]:contains("xls")').hide();
        }
    });
    var optionId = 0;
    $(".arrow1").click(function() {
        var divId = $(this).parent().attr("id");
        divId = divId.replace("out_div", "");
        var textValue = "#comment#" + $("#" + divId + "Text").val();

        var selToId = divId + "_rec";
        $("#" + divId + " option[selected='selected']").each(function() {
            var idOpt = $("#" + selToId).attr("id") + "option_" + optionId;

            $opt = $("&lt;option&gt;");
            $opt.attr("id", idOpt).attr("value", $(this).val() + textValue);
            $("#" + selToId).append($opt);
            var value = $(this).val().replace("#comment#", "");
            var divId = $("#" + selToId).attr('id') + 'option_div_' + optionId;
            var $de = $("&lt;div class='multi_select_div'&gt;&lt;img class='delete' src='images/delete.png'&gt;&lt;/img&gt;" + value + "&lt;/div&gt;").attr('id', divId);
            $de.appendTo("#" + $("#" + selToId).attr('id') + "_div");
            $("#" + divId).bind("click", handler);
            var optId = divToOption($(this).attr("id"));
            var optValue = $(optId).val();
            var comment = optValue.substring(optValue.indexOf("#comment#") + 9);
            $("#" + divId).attr("title", textValue.replace("#comment#", ""));
            //$("#"+divId).bind("mouseenter",handler2);
            //$("#"+divId).bind("mouseleave",handler3);
            $(".delete").bind("click", handler1);

            optionId++;
        });
        // function code
        //
    });

    $(".multi_select_div").click(function() {
        var id = divToOption($(this).attr('id'));
        var selected = $(id + "[selected]");

        if (selected.length &gt; 0) {
            $(id).attr('selected', false);
            var cssObj = {
                'background-color': 'black'
            };
            $(this).css(cssObj);

        }
        else {
            $(id).attr('selected', 'selected');
            var cssObj = {
                'background-color': 'orange'
            };
            $(this).css(cssObj);

        }
    });

    function handler(event) {
        var id = divToOption($(this).attr('id'));
        var selected = $(id + "[selected]");

        if (selected.length &gt; 0) {
            $(id).attr('selected', false);
            var cssObj = {
                'background-color': 'black'
            };
            $(this).css(cssObj);

        }
        else {
            $(id).attr('selected', 'selected');
            var cssObj = {
                'background-color': 'orange'
            };
            $(this).css(cssObj);

        }
    }

    function handler1(event) {
        $(this).parent().remove();

    }

    function handler2(event) {

        var optId = divToOption($(this).attr("id"));
        var optValue = $(optId).val();
        var comment = optValue.substring(optValue.indexOf("#comment#") + 9);
        var pos = $(this).position();
        var cssObj = {
            top: pos.top - 100,
            left: pos.left + 200
        };

        var $divImg = $("&lt;td&gt;");
        var $divCl = $("&lt;div class='comment'&gt;" + comment + "&lt;/div&gt;").css(cssObj);
        $divImg.append($divCl);
        $(this).parent().parent().parent().parent().append($divImg);

    }

    function handler3(event) {
        $(".comment").remove();
    }


});

function optionToDiv(option) {
    var id_div = option.replace('option_', 'option_div_');
    id_div = "#" + id_div;
    return id_div;

}

function divToOption(div) {
    var id_opt = div.replace('div_', '');
    id_opt = "#" + id_opt;
    return id_opt;

}​
</code></pre>
