is there a way to disable 'tab' on a input type='text'?

前端 未结 3 762
南旧
南旧 2021-02-20 12:38

is there a cross-browser solution to disable \'tab\' on a input type=\'text\' ?


Pressing \'tab\' moves you to the

3条回答
  •  执笔经年
    2021-02-20 13:09

    Yes,check if the key pressed was tab, and if so, returns false:

    jQuery('.noTab').find('input,select,textarea').keydown(function (e) { if (e.which === 9) { return false; } });

    jQuery will allow this work on legacy browsers.

    http://jsfiddle.net/JxMhY/

    On that fiddle it shows 2 forms, one with the class "noTab" and one without, as tab/shift+tab are useful for many forms, but not the one which has a special "tab" action.

提交回复
热议问题