Using jQuery to work around tabindex issues

I try to control my forms and how the user interacts with them through the property of the form elements. All my elements have tabindex, and I want this value to be respected and used correctly.

I'm currently developing Mac / Firefox, and I am aware of the default Mac system setting, which only sets tabs to input elements and lists. However, I want to override this and any other settings that may interfere with this in any system / browser.

I am using jQuery to try to get around this. Here is my code for now:

$(":input").keypress(function(e){
    if (e.which == 0)
    {
        tindex = parseInt($(this).attr("tabindex")) + 1;
        $(":input[tabindex='" + tindex + "']").focus();
    }
});

However, this does not work the way I want it. When the Mac setting is enabled by default, it actually skips tabindex and generally skips items without text / textarea. For example, if I am on input[tabindex=2], and I press the Tab key, they send me to input[tabindex=4]. If I am on input[tabindex=2]and there is a selectfield between input[tabindex=2]and input[tabindex=4], I am sent to input[tabindex=5].

I want you to input[tabindex=2]put me on input[tabindex=3], select[tabindex=3], input[type=radio][tabindex=3]and etc .; basically that tabindexof of 3.

Let me know of any ideas to get around this issue. Please also tell me if you know anything else in other systems / browsers that I should look at.

+3
1

e.preventDefault(); . , . , .

. .

+4

Source: https://habr.com/ru/post/1712940/


All Articles