我想将焦点放在多选框中的一个选项上。我只想要虚线边界线 (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/