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
Post a Comment