javascript press tab key

Solutions on MaxInterview for javascript press tab key by the best coders in the world

showing results for - "javascript press tab key"
Marcel
10 Jun 2016
1window.onkeypress = function(e) {
2    if (e.which == 13) {
3       e.preventDefault();
4       var nextInput = inputs.get(inputs.index(document.activeElement) + 1);
5       if (nextInput) {
6          nextInput.focus();
7       }
8    }
9};
Mika
02 Jul 2016
1window.onkeypress = function(e) {
2    if (e.which == 13) {
3        e.preventDefault();
4        var inputs = document.getElementsByClassName('input');
5        for (var i = 0; i < inputs.length; i++) {
6        if (document.activeElement.id == inputs[i].id && i+1 < inputs.length ) {
7            inputs[i+1].focus();
8            break;   
9        }
10    }
Santiago
12 Jul 2020
1var inputs = $(':input').keypress(function(e){ 
2    if (e.which == 13) {
3       e.preventDefault();
4       var nextInput = inputs.get(inputs.index(this) + 1);
5       if (nextInput) {
6          nextInput.focus();
7       }
8    }
9});