Crear y restablecer dinámicamente tabIndex de elementos HTML.
El atributo tabindex especifica el orden de tabulación de un elemento HTML, como el conjunto de "li", "a" e.t.c. El atributo tabindex es compatible con todos los principales navegadores.
Para esta instancia, configure set tabindex para los elementos de la lista "li". Por lo general, tabindex comenzará desde '0', sin embargo, podemos restablecerlo para comenzar desde '1'. Estoy usando Jquery para hacer esto.
See It Working Here
<ul id="dfruits">
<li>Apple</li>
<li>Dragonfruit</li>
<li>Damson</li>
<li>Cloudberry</li>
<li>Blueberry</li>
<li>Cherry</li>
<li>Blackcurrant</li>
<li>Coconut</li>
<li>Avocado</li>
<li>Pinaple</li>
</ul>
$(document).ready(function() {
var
SomeFruitsList=$("ul#dfruits li"),
//set tab index to starts from 1
tabindex = 0;
SomeFruitsList.each(function() {
// add tab index number to each list items
tabindex++;
$(this).attr("tabindex","TabIndex " +tabindex);
var tabIndex = $(this).attr("tabindex");
// add tab index number to each list items as their title
$(this).attr("title",tabIndex);
$(this).append('<br/><em>My tabIndex is number: '+tabIndex+'<em>')
})
});
1 para su avatar – MooGoo
$ ('# link3 ') .attr (' tabIndex ', 6); // para jQuery – marklark
El atributo es 'tabindex' pero' el.tabindex' no funciona, pero 'el.tabIndex' sí lo hace. Tan raro. –