重置TinyMCE框

时间:2011-05-23 15:10:58

标签: javascript jquery asp.net tinymce

我正在使用TinyMCE编辑器。我想在我的表单上点击一些按钮,清除编辑框内的内容。

你能告诉我怎么做吗?

5 个答案:

答案 0 :(得分:23)

使用以下代码作为按钮的onclick-action,可以轻松完成(无需使用慢速jQuery tinymce构建):

// '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(''); 

答案 1 :(得分:2)

TinyMCE jQuery Plugin documentation,您可以从您链接的页面轻松找到:

// 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());

尝试将其设置为空字符串,可能正是您所需要的。

答案 2 :(得分:0)

如果您对编辑器的清除内容感兴趣,可以使用: tinymce.get('#editorId')。setContent(''); //和其他人一样建议

但是,如果你想重置内容和菜单按钮等 - 基本上重置编辑器,你可以考虑使用: 。的 tinymce.get( '#editorId')的init();

答案 3 :(得分:0)

将指定的内容设置为编辑器实例,这将在使用设置之前清除内容 不同的清理规则选项。

tinymce.activeEditor.setContent('');

答案 4 :(得分:-1)

$('#name_of_your_textarea').val('');