您不能将表格单元格集中在所有浏览器上。这是 jQuery 文档所说的:
The focus event is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property. An element can gain focus via keyboard commands, such as the Tab key, or by mouse clicks on the element.
为了确保这适用于所有浏览器,您可以实现一些 CSS 类并为鼠标键添加事件侦听器。然后只需从表格单元格中添加/删除 css 类。
为了id="target"
使用这个来聚焦一个元素
$('#target').focus();