Vik*_*sal 5 html javascript jquery angularjs
我有两个组,我想为它们单独导航,并在按下 Tab 键时在组的最后一个选项卡控件上,然后应重新启动迭代周期,并且焦点应移动到组的初始元素(这将是 0指数)
在下面给出的示例中,我添加了两个组,在组中我添加了一些文本框并分配了非序列顺序。
问题
注意:我正在制作一个 angularjs 应用程序,这只是一个虚拟的应用程序,可以清晰地显示我的问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div role="group" tabindex="-1">
<h1>Group 1</h1>
<br>
<input type="text" tabindex="1" />
<br>
<input type="text" tabindex="6" />
<br>
<input type="text" tabindex="4" />
<br>
<input type="text" tabindex="2" />
<br>
<input type="text" tabindex="5" />
<br>
<input type="text" tabindex="2" />
<br>
<button tabindex="7">Submit</button>
</div>
<hr>
<div>
<div role="group" tabindex="-1">
<h1>Group 2</h1>
<br>
<input type="text" tabindex="1" />
<br>
<input type="text" tabindex="6" />
<br>
<input type="text" tabindex="4" />
<br>
<input type="text" tabindex="2" />
<br>
<input type="text" tabindex="5" />
<br>
<input type="text" tabindex="2" />
<br>
<button tabindex="7">Submit</button>
</div>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
非常感谢 @Kiran Nawale 和 @G\xc3\xb6khan Kurt 指导我找到解决方案。
\n\n我创建了一个通用指令,可用于任何角度应用程序。
\n\n依赖关系
\n\n在指令中,我添加了注释,这些注释将指导您完成指令的工作方式。
\n\n如何使用?
\n\n在您的元素中添加以下给定的属性和指令
\n\ntab-man tab-index="0" tab-group="g1"\n\ntab-man : the directive\ntab-index : it is the index of the element in the group\ntab-group : name of the group\nRun Code Online (Sandbox Code Playgroud)\n\n笔记:
\n\n每个组中应该始终有一个0索引,否则循环将不会重新开始。
0,1,2,4...如果像(被跳过)一样跳过任何索引3,则在 2 之后焦点将移至0
tab-man tab-index="0" tab-group="g1"\n\ntab-man : the directive\ntab-index : it is the index of the element in the group\ntab-group : name of the group\nRun Code Online (Sandbox Code Playgroud)\r\n