Focusing a DIV in JavaScript

It is possible to focus a DIV or another HTML elements with JavaScript by using the tabindex tag, this tag allows us to stablish whether an element can be focused or not, with “-1” value elements can’t be tabbed but it can be focused, with “0” value the element can be focused via the keyboard and tabbed following the normal flow of the document. Values greater than 0 set the priority level for this tab flow, 1 is the most important value.

JavaScript:

HTML:

Sources:
http://snook.ca/archives/accessibility_and_usability/elements_focusable_with_tabindex
http://www.sitepoint.com/article/accessible-javascript

Code in Fiddle:

https://jsfiddle.net/AlejandroMoran/416gxk4m/

Tagged with: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*