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

difference between .focus() and .select()

Mike Kypriotis
P: 37
whenever i see a js code wanting to move the cursor to a text input field I see e.g.
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("username").focus();
  2. document.getElementById("username").select();
  3.  
is not only focus enough?
Dec 7 '11 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
focus() is enough. select() will select the input ready for copying.
Dec 7 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.