Can I dynamically set tabindex in JavaScript?

Is there any attribute like tab-index?

CONTEXT : I'm making a section in a web form visible or invisible depending on some condition where I want to set the tab-index manually when that particular section is visible.


document.getElementById("link3").tabIndex = 6;

Using JQuery we can set tab index dynamically easily Try this code- set the tabindex and increment the variable

$(function() {
    var tabindex = 1;
    $('input,select').each(function() {
        if (this.type != "hidden") {
            var $input = $(this);
            $input.attr("tabindex", tabindex);

Dynamically create and reset tabIndex of an HTML elements.

The tabindex attribute specifies the tab order of an HTML element, such as set of "li","a" e.t.c. The tabindex attribute is supported in all major browsers.

For this instance let set tabindex for list items "li". Usually tabindex will start from '0', however we can reset it to start from '1'. I am using Jquery to do this.

See It Working Here

<ul id="dfruits">

$(document).ready(function() {

SomeFruitsList=$("ul#dfruits li"),
//set tab index to starts from 1
tabindex = 0;   

SomeFruitsList.each(function() {
 // add tab index number to each list items
$(this).attr("tabindex","TabIndex  " +tabindex); 

var tabIndex = $(this).attr("tabindex");
 // add tab index number to each list items as their title   

    $(this).append('<br/><em>My tabIndex is number:    '+tabIndex+'<em>')

Need Your Help

What's the difference between a continuation and a callback?

javascript continuations callcc continuation-passing

I've been browsing all over the web in search of enlightenment about continuations, and it's mind boggling how the simplest of explanations can so utterly confound a JavaScript programmer like myse...

How to create a single setup.exe with InstallShield limited edition?

visual-studio-2010 installshield-le

I am trying to create a single .exe file installer. I managed to get all the dependencies in to a .exe file (by setting extract from Setup.exe property). How do i get the .msi also inside the setup...