In typescript i need to implement specific caretPosition of an input element.But when i try to implement it shows createTextRange type does not exists in type HTMLElement. any one have solution for this?? Thanks in advance.
following is my code
private setCaretPosition() {
var el = document.getElementById("ticketInfo");
if (el !== null) {
if (el.createTextRange) {
var range = el.createTextRange();
range.move('character', el.value.length);
range.select();
return true;
}
else {
if (el.selectionStart || el.selectionStart === 0) {
el.focus();
el.setSelectionRange(length, length);
return true;
}
else { // fail city, fortunately this never happens (as far as I've tested) :)
el.focus();
return false;
}
}
}
}
it is showing createTextRange() undefined
el.setSelectionRange(length, length);
, where is length defined or assigned a value? – Grisham