javascript - document.getElementById ("ID").focus() + 谷歌浏览器

标签 javascript

document.getElementById("ID").focus() 在 Google Chrome 中不起作用。还有其他选择吗?谢谢。

最佳答案

如果您尝试聚焦通常无法聚焦的内容,您可能需要添加 tabindex:

<span id="something" tabindex="0">Something</span>

document.getElementById("something").focus()

关于javascript - document.getElementById ("ID").focus() + 谷歌浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2081587/

相关文章:

javascript - 将 key 添加到 firestore 文档时出现问题

javascript - 使用 JS 或 JQuery 的多个条件/禁用选择选项?

javascript - 单击查找元素并打开最近的模式窗口

javascript - 如何在javascript中获取div被点击的部分?

Javascript 无法在 XAMPP 上的 PHP 中运行

javascript - CreateJs - 距左侧的距离

javascript - 常规 js int 和 jquery.val() 中的 int 有什么区别?

javascript - Promise.all() 并不总是得到解决 - 编辑以添加两个函数的代码

javascript - IE 和 Safari 中的 File() 构造函数

javascript - Angularjs - 跨 Controller 计算