javascript - Why does setTimeout(myFunction, 0) work, but running the function itself not work? -


This code should select the contents of a Texter, when the text is selected, however, it does not work by itself:

  $ ("# form"). Focus (function () {$ ("# form"). Select ();});   

It only give then a setTimeout , such as:

  $ ( "# Form "). Focus (function () {setTimeout (function () {$ ("#Format"). Select ();}, 0);});   

Why is that so?

It looks like the first code, selecting the snippet, then deselecting the text I suspect that Text selection is being exposed after the event after the focus event is over, and after setTimeout select (when behind Things have already happened).

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -