jQuery focus not working in Chrome

前端 未结 4 1996
爱一瞬间的悲伤
爱一瞬间的悲伤 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:27

    I got the same problem and got it fixed using the following code:
    You should also have a name attribute for your input to get this working.

    $("#one").on("input", null, null, function() {  
       if($("#one").val().length == 2) {  
           setTimeout(function() { $('input[name="one"]').focus() }, 3000);  
       }  
    });  
    

    Hope this helps someone who did not get it working using the other suggestions.

提交回复
热议问题