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