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.
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.
tabindex = "-1" for readonly inputsThat is an interesting question; the more that CSS support is still not available.
Here is how tabindex can be set to -1 for all readonly input elements:
NodeList.prototype.forEach = NodeList.prototype.forEach || Array.prototype.forEach;
document.querySelectorAll('input[readonly="readonly"]').forEach(x => x.tabIndex = -1);
The first line ensures that the NodeList class is extended with the forEach method. This is further explained here.
Some useful JS:
for (let tabbable of document.querySelectorAll('[tabindex]')) {
}
element.setAttribute('tabindex', '-1');