Posts Tagged ‘Set Focus After Last Character in Text Box’


JQuery focus() after last character in textbox not woking in IE – Solution

May 7, 2015

In other browsers $(‘#TextBox’).focus() this code will work. for IE we need to do something special!!! in code

Code :

Create a function:

$.fn.setCursorToTextEnd = function() {
$initialVal = this.val();
this.val($initialVal + ‘ ‘);

also we need to use setTimeout.

setTimeout(function() {
}, 100);

Source 1
Source 2