如何在输入键上执行tabindex而不是角js中的tab键?

时间:2017-02-25 09:26:22

标签: javascript jquery angularjs

我在堆栈溢出时使用了这个指令,但这对selected指令不起作用。如何在另一个指令上执行此功能?

module.directive("nextFocus", function () {
    var directive = {
        restrict: 'A',
        link: function (scope, elem, attrs) {
            elem.bind('keydown', function (e) {
                var code = e.keyCode || e.which;
                if (code === 13) {
                    try {
                        if (attrs.tabindex != undefined) {
                            var currentTabIndex = attrs.tabindex;
                            var nextTabIndex = parseInt(attrs.tabindex) + 1;
                            $("[tabindex=" + nextTabIndex + "]").focus();
                        }
                    } catch (e) {

                    }
                }
            });
        }
    };
    return directive;
});

0 个答案:

没有答案