简体   繁体   English

无法在Chrome / Android的多选字段中取消选择所有选项

[英]Can't deselect all options in a multi select field on Chrome/Android

Very simple example: 很简单的例子:

<select id="multi" multiple="multiple">
  <option selected="selected">Option 0</option>
  <option>Option 1</option>
</select>
<script type="text/javascript">
  document.getElementById("multi").options[0].selected = false;
</script>

In the desktop version of Chrome, no options are selected after the code has run. 在桌面版Chrome中,运行代码后未选择任何选项。 In the Android version (tested on a Nexus 7 with Android 4.4.2), the first option is still selected. 在Android版本(在装有Android 4.4.2的Nexus 7上进行测试)中,第一个选项仍处于选中状态。 It seems that Chrome interprets "multiple" selection as "at least one". Chrome似乎将“多个”选择解释为“至少一个”。 Does anyone know of a workaround for this problem? 有谁知道解决此问题的方法?

This was a bug in Chrome for Android (version 30). 这是Android版Chrome(版本30)中的错误。 After updating to the latest version (35), deselecting the option works as expected. 更新到最新版本(35)后,取消选择该选项将按预期进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM