input 박스에서 focus 자동이동HIT

조회 2.5만

글자 입력후 포커스가 다음 input 박스로 자동으로 이동되는 소스

- jQuery

$(function() {
    $(".inputs").keyup (function () {
        var charLimit = $(this).attr("maxlength");
        if (this.value.length >= charLimit) {
            $(this).next('.inputs').focus();
            return false;
        }
    });
});

-html

<input type='text' class='inputs' maxlength='3' />

-설명

input 박스에 클래스명을 inputs 라고 넣고 maxlength 만큼 글이 입력되면

자동으로 다음 input 박스에 포커스가 이동됨.

한글은 잘 안됨...

#input#focus

📌프론트엔드 인기 글

목록으로 ›