javascript tinymce 4 如何将光标置于文本末尾

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19829126/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 16:57:36  来源:igfitidea点击:

tinymce 4 how to put cursor to end of the text

javascriptjqueryhtmltinymcetext-editor

提问by Hendry H.

For some reason, I need to execute :

出于某种原因,我需要执行:

tinyMCE.activeEditor.setContent(text, {format : 'html'});

After that, how to put the cursor to the end of the text ?

之后,如何将光标放在文本的末尾?

回答by Hendry H.

ed.selection.select(ed.getBody(), true); // ed is the editor instance
ed.selection.collapse(false);

This seems to be answered by Peter Wooster in thread jQuery Set Cursor Position in Text Area

这似乎是由 Peter Wooster 在线程jQuery Set Cursor Position in Text Area 中回答的

EDIT For TINYMCE use:

编辑对于 TINYMCE 使用:

tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
tinyMCE.activeEditor.selection.collapse(false);

回答by the_root

For tinyMCE 4+ better use:

对于 tinyMCE 4+ 更好的使用:

tinyMCE.activeEditor.focus();