1

I have a problem in IE -10(window -7 SP-1) when set focus on a text box. my cursor position at the beginning in text-box. how can i set position End of text-box value.

DEMO I am try j-query code for this problem --

var input = $("#txt1"); // textbox Id

var len = input.val().length;

input[0].focus();

input[0].setSelectionRange(len, len);

TRY WITH JQUERY CODE

WITH JQUERY problem is resolved but why cursor set beginning in IE-10(window -7 SP-1)?

And any any other solution for this.

Ishan Jain
  • 8,063
  • 9
  • 48
  • 75

1 Answers1

1

This appears to be an implementation choice on the part of the browser. I can't find anywhere in the HTML spec where it says where the cursor should be positioned when a text input gains focus. If you use the mouse to give an input focus, the cursor is at the clicked position in IE10, Firefox and Chrome, but absent a click event, the browsers seem to do their own thing - Chrome, for example, appears to select the entire contents of the input.

AmericanUmlaut
  • 2,817
  • 2
  • 17
  • 27
  • 1
    chrome does not select the entire content of the input. At least not these days? Anyways good answer. this is probably relevant, though :https://stackoverflow.com/a/31322665/4770754 – tatsu Apr 09 '18 at 09:43