javascript - move cursor to the beginning of the input field? -


When you click here to "ask questions", then "What is your programming question? Be descriptive. " / P>

I want the same thing and for all I need to have my cursor move to the beginning of the text field, how can i do this with jquery

There may be an overkill, but useful for these tasks, select a portion of an input field.

Put the cursor at the first letter of the second field in the code below.

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Then & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input value = "stack" /> & Lt; Input value = "overflow" /> & Lt; Script & gt; Var inp = document.getElementsByTagName ('INPUT') [1]; If (inp.createTextRange) {var part = inp.createTextRange (); Part.move ("Character", 0); Part.select (); } And if (inp.setSelectionRange) {inp.setSelectionRange (0, 0); } Inp.focus (); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -