0

I want to set the cursor position to last character in textbox.

I'm using this code.

$("#txt_search").focus();

In chrome it is set cursor to last but in mozilla it is in first.

Gowri
  • 1,832
  • 3
  • 29
  • 53

2 Answers2

0

You need to use it like this:

var data = $('#txt_search').val();
$('#txt_search').focus().val('').val(data);

See this for javascript solution by CMS

Community
  • 1
  • 1
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
  • Thanks for your quick reply but it not working.I'll check your link may be it will help me. – Gowri Jun 03 '14 at 06:49
0

Finally I got it.Using the Jquery Caret script. It is working in both chrome and mozilla.

Add jquery caret script in my file and used the following code.

var $inputExample = $('#txt_search');
$inputExample.caretToEnd();
Gowri
  • 1,832
  • 3
  • 29
  • 53