Set keyboard focus to a

you can make a div focusable if you add a tabindex attribute.

see: http://snook.ca/archives/accessibility_and_usability/elements_focusable_with_tabindex

The tabindex value can allow for some interesting behaviour.

  • If given a value of “-1”, the element can’t be tabbed to but focus can
    be given to the element programmatically (using element.focus()).
  • If given a value of 0, the element can be focused via the keyboard and
    falls into the tabbing flow of the document.
  • Values greater than 0 create a priority level with 1 being the most important.

UPDATE: added a simple demo at http://jsfiddle.net/roberkules/sXj9m/

Leave a Comment