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?
The task: to get rid of all tabindex with -1 value, add type="tex/javascript" for all script tags, type="text/css" for style tags and out an alt to all img tags. These are all for the sake of html validation.
A negative value (usually tabindex="-1" ) means that the element is not reachable via sequential keyboard navigation, but could be focused with JavaScript or visually by clicking with the mouse. It's mostly useful to create accessible widgets with JavaScript.
Yes. It is useful. The most useful values are tabindex="0" for example on <span/> or <div/> element and tabindex="-1" to disable tab stops or make elements focusable without tab-navigation. I created HTML+CSS libraries that use this.
@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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With