【问题标题】:how can i make the tabindex of the specific class every element to -1我怎样才能使特定类的每个元素的tabindex为-1
【发布时间】:2022-06-10 23:43:27
【问题描述】:

我正在尝试对要循环 div 的代码运行一个循环,如果该 div 内的任何元素上有任何选项卡索引,我希望它是 -1 而不是 0

我试过这段代码,但它不起作用,

document.querySelector('.app-container-grid').forEach((grid,index) => {
        grid.setAttribute("tabindex", -1); 
      });

它只是将 tabindex 保持为它所具有的任何值,并且不会将其更改为 -1

【问题讨论】:

  • 请在问题中添加示例 HTML。也许您的查询选择器是错误的。
  • 我的猜测是 .app-container-grid 匹配容器,而不是输入本身。您需要使用与输入匹配的选择器,可能是.app-container-grid input

标签: javascript


猜你喜欢
  • 2015-05-14
  • 2014-12-04
  • 1970-01-01
  • 2016-04-07
  • 2012-09-19
  • 1970-01-01
  • 2023-01-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多