0

I am trying to append an option dynamically to select onclick of itself as in following code. On Firefox it works fine. When clicked on select, it momentarily shows 2 options and it appends the new option.

But in Internet explorer 7, onclick of select, the list is collapsed. When clicked again, it shows the 3rd option appended. The firefox doesnt do the select collapse.

I want to have the same behavior in IE7. Is something missing?

TIA, Vipul

<head>
<script>
var done = false;
$(document).ready(function(){
    $("#filter_type").click(function (el) {
    if (done)
        return;
    $("<option>").val("r").text("s").appendTo($(this));

    done = true;
    });
});
</script>
</head>
<body>
<select id="filter_type">
<option value="x">Y</option>
<option value="t">V</option>
</select>
</body>

1 Answer 1

0

This bug has been reported here: http://bugs.jquery.com/ticket/3041

Apparently if you add the text to the option after appending it to the select list it will work. Your other option is to do something like the following:

$(this).append("<option value='r'>s</option>")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.