how to select the text and set the insertion point in a field

I want to (1) initialize a field to a particular value. Then (2) select the contents of that field so that if you type something in the field, it overwrites the value. Then (3) specify where the insertion point for the field should be. And then (4) change the focus so the field is "focused" when the app page is displayed.

I know that I can accomplish all of the above by manually clicking on the field and selecting the text, but I want to do it programatically. How can I do this?

I know:
(1) use .val(xx) to set the value of a field
I don't know how to do (2) or (3). And (4), .focus() doesn't work to get the field selected and the insertion point active. In fact, .focus() seems to be a no-op.

Any help here would be appreciated. Love your tool!
1 person has
this question