IE-10 Cursor position when set focus on textbox using jquery

 ̄綄美尐妖づ 提交于 2019-12-13 02:25:18

问题


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.


回答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.



来源:https://stackoverflow.com/questions/15430038/ie-10-cursor-position-when-set-focus-on-textbox-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!