Tab Index

Add a logical tab index. This is particularly important if you are working with content from a CMS or you don't have full control of the source code.

Setting all elements to tabindex="0" means they will be focused in the order they appear in the document.


jQuery(document).ready(function($) {
  $('a, input, select, button, textarea').attr('tabindex',0);

Native Javascript

var tabbable = ['a', 'input', 'select', 'button', 'textarea'];

for (var i = 0; i < tabbable.length; i++) {
  var elem = document.getElementsByTagName(tabbable[i]);
  for (var j = 0; j < elem.length; j++) {
    elem[j].setAttribute('tabindex', 0);