Skip to content Skip to sidebar Skip to footer

IOS Safari Selecting Multiple Options Visually For Single Select

I'm using this 'empty optgroup' workaround to get iOS to show option elements with long text in a readable manner. I'm using the following code to test this solution:

Choo

Solution 1:

I found this issue without the optgroup element, when I was programmatically re-populating and selecting a default item in a combo box, in response to another field changing. I found that I simply had to clear out the old selection first:

$("#time")[0].selectedIndex = -1 // this fixed it for me
$("#time option").each(function () {
        if ($(this).val() == oldtime) {
            $(this).attr("selected", "selected");
            return;
        }
});

Only Safari had this problem, it's clearly a bug that a single-select list can have two items visibly selected.


Post a Comment for "IOS Safari Selecting Multiple Options Visually For Single Select"