简体   繁体   English

有关使用Tabindex和javascript / jquery简化“制表”的建议

[英]Advice about using Tabindex and javascript/jquery to make “tabbing” easier

I'm making a large and complex application and I need to set tabindexes to help user navigate through the pages. 我正在制作一个大型而复杂的应用程序,我需要设置tabindexes来帮助用户浏览页面。 This is a private application so I don't have restriction about (ab)using javascript (jquery). 这是一个私人应用程序,因此我对(ab)使用javascript(jquery)没有任何限制。

I currently have these questions. 我目前有这些问题。

1) How do you force with javascript (jquery) the browser to move the cursor inside a specific textbox as soon as a page has loaded? 1)如何在页面加载后立即使用javascript(jquery)强制浏览器在特定文本框中移动光标? I noticed that often browsers don't automatically put the cursor inside the first tabindexed input. 我注意到,通常浏览器不会自动将光标置于第一个使用索引索引的输入中。 I want a surefire way that forces it there no matter what. 我想要一种无论如何都将其强制执行的安全射击方法。

2) Some fields that activate ui enanchement (namely jquery ui datepicker) have problems with tabbing (like having to push tab two time to go away from it), is there any way to avoid this? 2)一些激活ui启用的字段(即jquery ui datepicker)在制表时遇到问题(例如必须两次按制表键才能离开它),有什么办法可以避免这种情况?

3) How do you read and set tabindex with jquery? 3)如何使用jquery读取和设置tabindex? I have some fields that get hidden/shown based on user action and they should be able to "give" their tabindex to other fields if they get hidden, is this a problem, does the browser still consider a tabindex after the page has loaded? 我有一些根据用户操作隐藏/显示的字段,如果它们被隐藏,它们应该能够将其tabindex赋予其他字段,这是一个问题,浏览器在页面加载后仍会考虑tabindex吗?

Thank you very muchh 非常感谢你

  1. To put focus on a specific textbox, do this (assuming textbox id is #firstBox): $('#firstBox').focus(); 要将焦点放在特定的文本框上,请执行以下操作(假设文本框ID为#firstBox): $('#firstBox').focus(); See more examples here: How do you automatically set the focus... 在此处查看更多示例: 如何自动设置焦点...
  2. Not particularly because the DatePicker is also its own UI, so it has various objects within it that can be focused on (which is what tabbing picks up on). 并不是特别重要,因为DatePicker也是其自己的UI,因此其中具有可重点关注的各种对象(制表符就是该对象)。
  3. Actually, now that I've thought about it, if you hide a field (AKA, "hidden") it will not have a tabindex and the other tabs will fall in line with what is defined for the browser (typically top to bottom, left to right order). 实际上,现在我已经考虑过了,如果您隐藏一个字段(又名“隐藏”),则该字段将没有tabindex,而其他选项卡将与为浏览器定义的内容一致(通常是从上到下,从左到右的顺序)。 You shouldn't have to worry about setting the tabindex manually. 您不必担心手动设置tabindex。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM