Disabling tab focus on form elements

后端 未结 7 1411
死守一世寂寞
死守一世寂寞 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:54

    Similar to Yipio, I added notab="notab" as an attribute to any element I wanted to disable the tab too. My jQuery is then one line.

    $('input[notab=notab]').on('keydown', function(e){ if (e.keyCode == 9)  e.preventDefault() });
    

    Btw, keypress doesn't work for many control keys.

提交回复
热议问题