editor.focus();
Sets the focus fine in Chrome. But in Firefox, the focus is set on the beginning on the line. I want it to be set on the end of the line. I tried this:
moveCaretToEnd(ed);
function moveCaretToEnd(el) {
if (typeof el.selectionStart == "number") {
el.selectionStart = el.selectionEnd = el.value.length;
} else if (typeof el.createTextRange != "undefined") {
el.focus();
var range = el.createTextRange();
range.collapse(false);
range.select();
}
}
And stupid FF doesn't work again. The focus is gone.
I used the following hack for firefox:
var value = editor.val();
editor.val("");
editor.focus();
editor.val(value);
Here is working fiddle: http://jsfiddle.net/vyshniakov/p37ax/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With