jQuery focus not working in Chrome

前端 未结 4 1988
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-17 08:24

Please see this fiddle: http://jsfiddle.net/yg49k/

The following code works fine in FireFox but doesn\'t work in the latest version of Chrome.

HTML:

4条回答
  •  执笔经年
    2020-12-17 08:30

    You should use:

    $("#one").on("keyup paste",function() {
        console.log($(this).val());
        if($(this).val().length == 2) { $("#two").focus(); }
    });
    

    DEMO

    And the same for the #five handler.

    The oninput event seems to have the same behaviour as onkeypress.

提交回复
热议问题