Wednesday, November 7, 2012
How to put the pointer at the last character in text box
$(function() {
$.fn.selectRange = function(start, end) {
return this.each(function() {
var self = this;
if (self.setSelectionRange) {
self.focus();
self.setSelectionRange(start, end);
} else if (self.createTextRange) {
var range = self.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', start);
range.select();
}
});
};
var slen = $('#loginEmail').val().length;
$('#loginEmail').selectRange(slen, slen+1);
});
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment