我必须使用optgroup显示下拉列表,如下所示:
HTML:
<select id="Cities" name="Cities">
<optgroup label="Group1">
<option value="City1">City1</option>
<option value="City2">City2</option>
<option value="City3">City3</option>
<option value="City4">City4</option>
<option value="City5">City5</option>
</optgroup>
<optgroup label="Group2">
<option value="City6">City6</option>
<option value="City7">City7</option>
<option value="City8">City8</option>
<option value="City9">City9</option>
<option value="City10">City10</option>
</optgroup>
</select>
JavaScript的:
$('#Cities').val('City1');
我需要设置一个选定值,但是当我使用safari IPhone5 +浏览时,它总是设置两个值。