禁用特定div上的制表符键 [英] Disable tab key on a specific 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上。
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屋!