javascript 将光标移动到 contenteditable 的末尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6990883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Move cursor to end of contenteditable
提问by Leticia Meyer
Possible Duplicate:
How to move cursor to end of contenteditable entity
How do I move the cursor to the end of a contenteditable div? I only need a solution that works in webkit, I dont care about ie or ff here. The shorter, the better. :-)
如何将光标移动到 contenteditable div 的末尾?我只需要一个适用于 webkit 的解决方案,我不在乎这里的 ie 或 ff。越短越好。:-)
采纳答案by Jason Gennaro
The first answer you looked at will work for a textarea, but not for a contenteditable element.
您查看的第一个答案适用于 textarea,但不适用于 contenteditable 元素。
This solution is for moving the caret to the end of a contenteditable element.
此解决方案用于将插入符号移动到 contenteditable 元素的末尾。