jt
2023-09-06 e792217d89c64aeacf543c91313cb05841e64e6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(function($) {
    $.enterfocus = function(selector, callback) {
        var boxArray = [].slice.call(document.querySelectorAll(selector));
        for (var index in boxArray) {
            var box = boxArray[index]; 
            box.addEventListener('keyup', function(event) {
                if (event.keyCode == 13) {
                    var boxIndex = boxArray.indexOf(this);
                    if (boxIndex == boxArray.length - 1) {
                        if (callback) callback();
                    } else {
                        //console.log(boxIndex);
                        var nextBox = boxArray[++boxIndex];
                        nextBox.focus();
                    }
                }
            }, false);
        }
    };
}(window.mui = window.mui || {}));