问问题
18681 次
2 回答
54
optgroup
在选择列表的末尾添加一个空:
<select>
<option selected="" disabled="">Select a value</option>
<option>Grumpy wizards make toxic brew for the evil Queen and Jack</option>
<option>Quirky spud boys can jam after zapping five worthy Polysixes</option>
<option>The wizard quickly jinxed the gnomes before they vaporized</option>
<option>All questions asked by five watched experts amaze the judge</option>
<optgroup label=""></optgroup>
</select>
于 2013-11-01T20:00:54.587 回答
17
与上面的答案类似,但使用 JS 为文档中的每个选择添加一个空的 optgroup:
// iOS 7 hack: Add an optgroup to every select in order to avoid truncating the content
if (navigator.userAgent.match(/(iPad|iPhone|iPod touch);.*CPU.*OS 7_\d/i)) {
var selects = document.querySelectorAll("select");
for (var i = 0; i < selects.length; i++ ){
selects[i].appendChild(document.createElement("optgroup"));
}
}
希望这对遇到同样问题的人有用。
于 2014-03-11T11:50:53.907 回答