How to set Cursor in TextField?

What are good ways to set focus on textarea and move cursor to the end of its value?

  • I have a hidden textarea with have a value. When user show that textarea I want it focus and set cursor to the end of current value. I tried $('#textarea').focus() but cursor is in the beginning of value.

  • Answer:

    What you want is the jCarat plugin. It lets you set carat position (among many other things). http://plugins.jquery.com/project/jCaret

Dan Ray at Quora Visit the source

Was this solution helpful to you?

Other answers

$('#textarea').selectionStart = $('#textarea').selectionEnd = $('#textarea').value.length;

George Papadakis

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.