javascript - jQuery focus not working in Chrome -


please see fiddle: http://jsfiddle.net/yg49k/

the following code works fine in firefox doesn't work in latest version of chrome.

html:

<input type="text" id="one" placeholder="type 2 chars" /> <input type="text" id="two" placeholder="it should focus here" /> 

jquery:

$("#one").on("input", function() {     if($("#one").val().length == 2) { $("#two").focus(); } }); 

does know how can around this?

seems bug in chrome. fast execute events properly;)

found workaround http://jsfiddle.net/rd2rz/

$("#one").on("input", function() {     if($("#one").val().length == 2) {          settimeout(function(){             $("#two").focus();         }, 1);     } }); 

use settimeout minimal delay. slow down chrome , make work.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -