Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing a tab stop on a hidden element? Possible?

The site is here

I have opt to using the radiobutton's labels as customized buttons for them. This means the radio inputs themselves are display:none. Because of this, the browsers don't tab stop at the radio labels, but I want them to.

I tried forcing a tabindex to them, but no cigar.

I have came up with just putting a pointless checkbox right before the labels, and set it to width: 1px; and height 1px; which seems to only really work on chrome & safari.

So do you have any other ideas for forcing a tab stop at those locations without showing an element?

Edit:

Just incase someone else comes by this, this is how I was able to insert small checkboxes into chrome & safari using JQuery:

if ($.browser.safari) {
    $("label[for='Unlimited']").parent().after('<input style="height:1px; width:1px;" type="checkbox">');
    $("label[for='cash']").parent().after('<input style="height:1px; width:1px;" type="checkbox">');
    $("label[for='Length12']").parent().after('<input style="height:1px; width:1px;" type="checkbox">');
}

Note: $.browser.webkit was not becoming true...so I had to use safari

like image 974
ParoX Avatar asked Aug 21 '10 12:08

ParoX


People also ask

How do you stop a tab from focusing?

To prevent tab indexing on specific elements, you can use tabindex="-1". If the value is negative, the user agent will set the tabindex focus flag of the element, but the element should not be reachable with sequential focus navigation. Note that this is an HTML5 feature and may not work with old browsers.

What does Tabindex =- 1 mean?

A negative value (usually tabindex="-1" ) means that the element is not reachable via sequential keyboard navigation, but could be focused with JavaScript or visually by clicking with the mouse. It's mostly useful to create accessible widgets with JavaScript.

How do you make an element not Tabbable?

The way to do this is by adding tabindex="-1" . By adding this to a specific element, it becomes unreachable by the keyboard navigation. There is a great article here that will help you further understand tabindex.

What is the difference between Tabindex 0 and Tabindex =- 1?

tabindex="1" (or any number greater than 1) defines an explicit tab or keyboard navigation order. This must always be avoided. tabindex="0" allows elements besides links and form elements to receive keyboard focus.


1 Answers

Keep the radio input hidden, but set tabindex="0" on the <label> element of reach radio input.

(A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.)

like image 140
strager Avatar answered Sep 28 '22 02:09

strager