javascript - 如何将焦点放在多选框中的选项上

标签 javascript css focus

我想将焦点放在多选框中的一个选项上。我只想要虚线边界线 (click here to refer image)在多选框中的一个选项上,不希望该选项被完全选中。

我尝试了类似 document.getElementById("multiple_dropdown").options[2].focus();但没有用。

有什么想法吗?

谢谢。

最佳答案

经过更多调查,我发现不值得花时间尝试更改不同浏览器的默认行为,即它们如何关注多选框中的选项,原因是浏览器提供的选项不多访问多个下拉列表中的

Browser | What happens on focus of multiple dropdown after reset ?                     | Is there provision to style/focus a particular option in multiple dropdown ?
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FF      | Dotted outline border on the very first option in the multiple dropdown      | We can’t set focus on a particular option, but will be able to style particular option like a dotted blue border or background etc.
IE      | Dotted outline border on the lastly selected option in the multiple dropdown | Doesn’t provide way to style/focus particular option in a multiple dropdown
Chrome  | No dotted outline on the option but a Solid thick blue border on the whole multiple dropdown itself | Doesn’t provide way to style/focus particular option in a multiple dropdown
Mac     | Same as chrome (as both are webkit family)                                   | Doesn’t provide way to style/focus particular option in a multiple dropdown

关于javascript - 如何将焦点放在多选框中的选项上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19160848/

相关文章:

javascript - 在 Angular 6 中拖放表格行

外部 .js 文件中的 PHP 语法问题

javascript - 如何优化这个js(现在页面打开时CPU超过40%)

css - 在 Firefox 中将高度调整为容器宽度的 100%

javascript - 创建显示新 div 的 div 样式

html - 使用 CSS 或剪辑路径悬停时的等距 45 度(长/对 Angular 线)阴影

python - 调用 pylab.show 时如何将焦点保持在命令提示符上?

javascript - 放映后将焦点设置到 div

delphi - 改变TEdits Delphi Xe5焦点的正确方法

javascript - 单独定位每个 DIV