[英]How to disable and re-enable tabindex of hidden/visible elements?
How can I change the tabindex
of an element based on whether or not the element is visible (in view-able area)? 如何根据元素的可见性(在可查看区域中)更改元素的
tabindex
? I would like to do one of these things: reset the current tabindex
upon entering a new section and assign new tabindex
's to the elements in that section. 我想执行以下操作之一:在进入新部分时重置当前的
tabindex
,并将新的tabindex
分配给该部分中的元素。 Or be able to disable and re-enable tabindex
's of certain elements. 或者能够禁用和重新启用某些元素的
tabindex
。
html: 的HTML:
<div id="nav">
<a id="firstLink" href="#section1" tabindex="1">Go to section 1</a>
<a id="secondLink" href="#section2" tabindex="2">Go to section 2</a>
</div>
<div id="container">
<div id="section1">
<a href="#" tabindex="3">Specific to section 1</a>
</div>
<div id="section2">
<a href="#" tabindex="3">Specific to section 2</a>
</div>
</div>
I want the links to be in the tabbing order ONLY if their section is visible. 我只希望链接在可见的地方按跳格顺序显示。
css: CSS:
#container{
overflow: hidden;
width: 400px;
height: 400px;
}
#section1{
background: red;
width: 400px;
height: 400px;
}
#section2{
background: green;
width: 400px;
height: 400px;
}
Live example: http://jsfiddle.net/2UF3n/5/ 实时示例: http : //jsfiddle.net/2UF3n/5/
您可以动态地从任何隐藏字段中添加或disabled="disabled"
,以使其tabindex
值被忽略。
$("a:hidden").attr("disabled","disabled");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.