Disabling tab focus on form elements

后端 未结 7 1410
死守一世寂寞
死守一世寂寞 2020-12-04 15:00

I have several divs within the same form. What I am trying to do is to disable the Tab key in one of the divs in the form without disabl

7条回答
  •  执笔经年
    2020-12-04 15:46

    Building on Terry's simple answer I made this into a basic jQuery function

    $.prototype.disableTab = function() {
        this.each(function() {
            $(this).attr('tabindex', '-1');
        });
    };
    
    $('.unfocusable-element, .another-unfocusable-element').disableTab();
    

提交回复
热议问题