When i was set focus on HTML control after set data,working fine in firefox.
But in IE 10 it focus on starting text, But i want focus on text end.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 3, 2015, 3:14 AM EDT
$.fn.focusTextToEnd = function(){
this.focus();
var $thisVal = this.val();
this.val('').val($thisVal);
return this;
}
}(jQuery));
var inputField = document.getElementById(id);
if (inputField != null && inputField.value.length != 0){
if (inputField.createTextRange){
var FieldRange = inputField.createTextRange();
FieldRange.moveStart('character',inputField.value.length);
FieldRange.collapse();
FieldRange.select();
}else if (inputField.selectionStart || inputField.selectionStart == '0') {
var elemLen = inputField.value.length;
inputField.selectionStart = elemLen;
inputField.selectionEnd = elemLen;
inputField.focus();
}
}else{
inputField.focus();
}
}
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 3, 2015, 3:04 AM EDT
Maria Johnson27 reputationPosted Aug 3, 2015, 3:09 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 3, 2015, 3:19 AM EDT
Maria Johnson27 reputationPosted Aug 3, 2015, 4:13 AM EDT