禁用特定div上的制表符键 [英] Disable tab key on a specific div

查看:92
本文介绍了禁用特定div上的制表符键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下结构:

 < div id =wrapper> 
< div id =div1>某些内容< / div>
< div id =div2>部分内容< / div>
< / div>

我想禁用div2上的tab键,我的意思是div2的元素不会当按Tab键时收到焦点。



有没有简单的方法可以使用javascript / jquery创建这个tab键阻塞程序?

解决方案

@John Strickler是对的。 tab键的行为可以通过tabindex属性进行更改。



随着< div id =div1tabindex = - 1>一些内容< / div> 您应该防止焦点在您的div上。

/www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.htmlrel =noreferrer> http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html


I have the following structure:

<div id="wrapper">
   <div id="div1">Some content</div>
   <div id="div2">Some content</div>
</div>

I want to "disable" the tab key on div2, I mean the elements of div2 won't receive focus when the tab key is pressed.

Is there any easy way to create this tab key blocker using javascript/jquery?

解决方案

@John Strickler is right. The behaviour of the tab key can be changed with the tabindex attribute. It is the order the elements will have the focus.

With <div id="div1" tabindex="-1">Some content</div> you should prevent the focus to be on your div.

More info here: http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html

这篇关于禁用特定div上的制表符键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆