admin管理员组文章数量:1293521
How can I change the tabindex
of an element based on whether or not the element is visible (in view-able area)? 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. Or be able to disable and re-enable tabindex
's of certain elements.
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:
#container{
overflow: hidden;
width: 400px;
height: 400px;
}
#section1{
background: red;
width: 400px;
height: 400px;
}
#section2{
background: green;
width: 400px;
height: 400px;
}
Live example: /
How can I change the tabindex
of an element based on whether or not the element is visible (in view-able area)? 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. Or be able to disable and re-enable tabindex
's of certain elements.
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:
#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/2UF3n/5/
Share asked Sep 20, 2012 at 19:14 Jake ZeitzJake Zeitz 2,5744 gold badges26 silver badges44 bronze badges1 Answer
Reset to default 5You can dynamically add or remove disabled="disabled"
from any hidden field to make its tabindex
value ignored.
$("a:hidden").attr("disabled","disabled");
本文标签: javascriptHow to disable and reenable tabindex of hiddenvisible elementsStack Overflow
版权声明:本文标题:javascript - How to disable and re-enable tabindex of hiddenvisible elements? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741578286a2386419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论