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

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -