By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,517 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,517 IT Pros & Developers. It's quick & easy.

Set cursor position to the end of a text field ?

P: n/a
Hi,
I can set focus on a text field. But the cursor is always stay at the
beginning , how to set the cursor at the end ?

Thank you.

Aug 10 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Who
"duzuike" wrote
I can set focus on a text field. But the cursor is always stay at
the beginning , how to set the cursor at the end ?

Thank you.


In some browsers, including IE and FF, the trick is to set the value of the
element after setting the cursor. The cursor will then be moved with it as
the new value is written and end up at the end...

tt.focus(); tt.value = tt.value;

Otherwise, you will need to manipulate text selection ranges, which is a
pain to do crossbrowser.
hth
ivo
http://4umi.com/
Aug 10 '05 #2

P: n/a
Thank you for your valuable reply. It works.

Aug 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.