duplicate-id-active
它能做什么
这项技能检查页面上的交互元素(例如链接、按钮和输入框)是否各自拥有唯一的 ID。适合希望导航可靠、具有无障碍性的开发者。
适用场景
- ✓当键盘焦点在你的页面上跳到了错误的位置时。
- ✓当你复制组件后,某个按钮触发了错误的操作时。
- ✓当你在审查页面的无障碍问题时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/duplicate-id-active/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能检查我页面按钮和链接上是否有重复的 ID 吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在页面中搜索在可聚焦元素上出现多次的 ID。然后建议为每个元素设置唯一的 ID,并更新对它的所有引用。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use unique IDs for active elements
Duplicate IDs on active elements can cause browsers and assistive technologies to skip items, misdirect focus, or fail to trigger the correct action.
Quick Reference
- Ensure all focusable elements (links, buttons, inputs) have unique id values
- Avoid duplicate IDs that can break keyboard navigation and focus management
- Prevent screen reader confusion when navigating interactive controls
Check
Search for duplicate id attributes on focusable or active HTML elements.
Fix
Assign a unique id to each active element to ensure correct focus handling and accessibility.
Explain
Explain how unique IDs on active elements prevent navigation errors for keyboard and screen reader users.
Code Review
Review the rendered markup and interactive states that affect Use unique IDs for active elements. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/duplicate-id-active
常见问题
重复的 ID 为什么会造成问题?
浏览器和辅助工具可能选中错误的元素,从而跳过某些项目或触发错误的操作。
检查哪些元素?
这项技能重点检查可聚焦的元素,例如链接、按钮和输入框。
如何确认修复有效?
这项技能建议使用浏览器的无障碍工具或辅助技术进行检查。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Use unique IDs for active elements. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2824
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。