javascript 重置 TinyMCE 框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6099148/
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
Reset TinyMCE box
提问by Rocky Singh
回答by Thariama
This can be easily done (no need to use the slow jQuery tinymce build) using the following code as onclick-action of your button:
这可以轻松完成(无需使用缓慢的 jQuery tinymce 构建),使用以下代码作为按钮的 onclick-action:
// 'content' is tinymce default,
// but if your textarea got an ID that is the one you need!
var my_editor_id = 'content';
// set the content empty
tinymce.get(my_editor_id).setContent('');
回答by DarthJDG
From the TinyMCE jQuery Plugin documentation, can be easily found from the page you linked:
从TinyMCE jQuery 插件文档 中,可以从您链接的页面轻松找到:
// Will change the contents of an textarea with the ID "someeditor"
$('#someeditor').html('Some contents...');
// Will change the contents all text areas with the class tinymce
$('textarea.tinymce').html('Some contents...');
// Gets the contents from a specific editor
alert($('#someeditor').html());
Try setting it to empty string, might be just what you need.
尝试将其设置为空字符串,可能正是您所需要的。
回答by user2570747
If you are interested in clearing the contentof the editor you can use: tinymce.get('#editorId').setContent('');// like others have suggested
如果您有兴趣清除编辑器的内容,可以使用: tinymce.get('#editorId').setContent(''); // 就像其他人建议的那样
However, if you'd like to reset the content and menu buttons etc. - essentially resetting the editor altogetheryou might consider using: tinymce.get('#editorId').init();
但是,如果您想重置内容和菜单按钮等 -基本上完全重置编辑器,您可以考虑使用: tinymce.get('#editorId').init();
回答by naspinski
$('#name_of_your_textarea').val('');