Aktuelles & Updates von
Joomla, Wordpress und Co.
News, HowTos und Tutorials rund um Webdesign, Webentwicklung, Webhosting und Digitalisierung.
tabindex für Formulare setzen per jQuery
In manchen Formularkomponenten hat man nicht die Möglichkeit die für die Usability und Barrierefreiheit wichtigen "tabindex" zu setzen. Mit dem Folgendne Skript ist das kinderleicht nachzuholen.
Diese Funktion sucht Elemente mit [name=' * '] und fügt das Attribut " tabindex=' * ' " hinzu.
<script type='text/j-avascript'>(function( $ ){ $(document).ready(function(){ $( "select[name='anrede']" ).prop('tabindex', '1'); $( "input[name='name']" ).prop('tabindex', '2'); $( "input[name='prename']" ).prop('tabindex', '3'); $( "input[name='strasse']" ).prop('tabindex', '4'); $( "input[name='plz']" ).prop('tabindex', '5'); $( "input[name='ort']" ).prop('tabindex', '6'); $( "input[name='email']" ).prop('tabindex', '7'); $( "input[name='geburtstag']" ).prop('tabindex', '8'); }); })( jQuery );</script>
Das Ergebnis sieht wie folgt aus ...
<input name="name" value="" size="40" class="required" aria-required="true" aria-invalid="false" tabindex="2" type="text">