This tutorial shows you how to use Javascript code to put the mouse cursor (or more accurately, the caret) in a textbox (input type="text") or textarea in the following ways:

  • How to put cursor in input textbox or textarea.
  • How to put cursor in input textbox or textarea at the BEGINNING or start of the text.
  • How to put cursor in input textbox or textarea at the END of the text.
  • How to put cursor in input textbox or textarea at a SPECIFIC POSITION.

The JS code required is actually quite simple and straightforward. The tutorial also includes demo pages to show the Javascript code in action ...