关于使用 Tabindex 和 javascript/jquery 进行“制表符”操作的建议更轻松

发布于 2024-09-25 02:42:28 字数 458 浏览 4 评论 0原文

我正在制作一个大型且复杂的应用程序,我需要设置选项卡索引来帮助用户浏览页面。这是一个私人应用程序,因此我对使用 javascript (jquery) 没有任何限制。

我目前有这些问题。

1) 如何使用 javascript (jquery) 强制浏览器在页面加载后立即将光标移动到特定文本框中?我注意到浏览器通常不会自动将光标放在第一个制表符索引输入中。我想要一种万无一失的方法,无论如何都会迫使它到达那里。

2)一些激活ui enanchement的字段(即jquery ui datepicker)存在选项卡问题(例如必须按两次选项卡才能离开它),有什么方法可以避免这种情况吗?

3)如何用jquery读取和设置tabindex?我有一些字段根据用户操作隐藏/显示,如果它们被隐藏,它们应该能够将其 tabindex“给予”其他字段,这是一个问题,浏览器在页面加载后是否仍然考虑 tabindex?

非常感谢你

I'm making a large and complex application and I need to set tabindexes to help user navigate through the pages. This is a private application so I don't have restriction about (ab)using 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? 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?

3) How do you read and set tabindex with jquery? 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?

Thank you very muchh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野心澎湃 2024-10-02 02:42:28
  1. 要将焦点放在特定文本框上,请执行以下操作(假设文本框 ID 为 #firstBox): $('#firstBox').focus(); 请在此处查看更多示例:如何自动设置焦点.. .
  2. 并不是特别重要,因为 DatePicker 也是它自己的 UI,因此它内部有各种可以关注的对象(这就是选项卡选择的对象)。
  3. 实际上,现在我已经考虑过这一点,如果您隐藏一个字段(又名“隐藏”),它将没有 tabindex,并且其他选项卡将符合浏览器的定义(通常是从上到下,从左到右的顺序)。您不必担心手动设置 tabindex。
  1. To put focus on a specific textbox, do this (assuming textbox id is #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).
  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). You shouldn't have to worry about setting the tabindex manually.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文