是的,我对 chrome/jquery mobile 有疑问。在 Internet Explorer 中,脚本似乎运行良好。
这是 jsfiddle示例
问题是当我在单击后从两个列表中选择多个项目时,它会很好。当我第二次这样做时,列表不再被清除。
HTML 代码:
<!-- Select Multiple -->
<div class="control-group" style="float: left;">
<label class="control-label" for="selectmultiple">Licentie Man</label>
<div class="controls">
<select id="maleLicense" style="height: 210px;" name="maleLicense" class="input-medium" multiple="multiple">
<option value="l0000000000000000000100">Amateur</option>
<option value="l0000000000000000000001">Basislid</option>
<option value="l0000000000000000001000">Belofte</option>
<option value="l0000000000000000010000">Elite</option>
<option value="l0000000000000000100000">Jeugd</option>
<option value="l0000000000000001000000">Junior 1e jaars</option>
<option value="l0000000000000010000000">Junior 2e jaars</option>
<option value="l0000000000000100000000">Nieuweling 1e jaars</option>
<option value="l0000000000001000000000">Nieuweling 2e jaars</option>
<option value="l0000000000100000000000">Professional-A</option>
<option value="l0000000000010000000000">Professional-B</option>
<option value="l0000000001000000000000">Sportklasse</option>
</select>
</div>
</div>
<!-- Select Multiple -->
<div class="control-group">
<label class="control-label" for="selectmultiple">Licentie Vrouw
</label>
<div class="controls">
<select id="femaleLicense" style="height: 210px;" name="femaleLicense" class="input-medium" multiple="multiple">
<option value="l0000000010000000000000">Amateur</option>
<option value="l0000000000000000000010">Basislid</option>
<option value="l0000000100000000000000">Belofte</option>
<option value="l0000001000000000000000">Elite</option>
<option value="l0000010000000000000000">Jeugd</option>
<option value="l0000100000000000000000">Junior 1e jaars</option>
<option value="l0001000000000000000000">Junior 2e jaars</option>
<option value="l0010000000000000000000">Nieuweling 1e jaars</option>
<option value="l0100000000000000000000">Nieuweling 2e jaars</option>
<option value="l1000000000000000000000">Professional-B</option>
</select>
</div>
</div>
<a id="click">empty input</a>
jQuery代码:
$(document).ready(function() {
$("a#click").click(function(){
"use strict";
$('#maleLicense').children(':selected').removeProp('selected');
$('#femaleLicense').children(':selected').removeProp('selected');
});
});
一张图片以直观地显示我的意思: