Reputation: 26939
In Mobile Safari on the iPad, it seems that if there is no option selected on a <select>
element, then the user cannot select the 0th option before selecting another one first (try it on http://jsfiddle.net/PJTKq/ on an iPad).
To be more specific:
<select>
element with two or more options.selectedIndex = -1
or removing the "selected"
attribute from all the <option>
elements.Does anyone know of a workaround (besides inserting an empty dummy option) that would allow moving directly from selectedIndex
-1 to selectedIndex
0?
Upvotes: 6
Views: 3661
Reputation: 11
<script>
// with jQuery
var iPad = !!navigator.userAgent.match(/iPad/i),
select = "select";
if(iPad === true) {
$(select).prop("selectedIndex", 0);
}
</script>
Upvotes: 1
Reputation: 5071
Until the bug is fixed, perhaps you could detect the user-agent and make selectedIndex=0
the default for Mobile Safari.
Upvotes: 0