Last active
July 15, 2020 16:01
-
-
Save neodigm/b8f59ab4f99ab3c34c511779f564584c to your computer and use it in GitHub Desktop.
JavaScript | Remove ALL positive tabIndex on the entire page | ES5 | A11y Testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove ALL tabIndex on the entire page - Thats a fun thing to do. ES5 | |
// From the entire document remove tabIndex if its value is greater than 0 | |
[].slice.call( document.querySelectorAll("[tabIndex]") ).filter(function(el){ // Neodigm 2020 | |
console.log("-- | " + el.tabIndex ); | |
if( el.tabIndex >= 1 ){ | |
el.tabIndex = ""; | |
} | |
}); | |
// From the entire document add a tabIndex="0" attrib if an A has no href | |
[].slice.call( document.querySelectorAll("A") ).filter(function(el){ | |
//console.log("== | " + el.tabIndex, el.href ); | |
if( !el.href ){ | |
el.tabIndex = 0; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIPS: