包含div或模态中的tab键

时间:2016-05-13 06:47:47

标签: angularjs bootstrap-modal tabcontrol

我有一个使用angularjs构建的应用程序。在一个页面上,我有一个带有表单元素的模式弹出窗口(元素不在表单标签内,由按钮和输入标签组成)。当bootstrap模式打开时,焦点位于第一个输入元素上。是否有一种方法可以将tab键按下事件仅包含到引导模式弹出窗口,因为当我按Tab键几次,控件进入浏览器地址栏,我可以编辑URL。我不想要这种行为,标签按下应该只允许用户关注弹出窗口。

1 个答案:

答案 0 :(得分:0)

我想你会在这里找到答案

$('#confirmCopy :input:first').focus();

$('#confirmCopy :input:last').on('keydown', function (e) { 
    if ($("this:focus") && (e.which == 9)) {
        e.preventDefault();
        $('#confirmCopy :input:first').focus();
    }
});

Keep tabbing within modal pane only