我必须使用ckeditor编辑textarea。编辑器后面放置一个按钮。如果单击该按钮,我需要向编辑器添加html代码。 加载CK编辑器的代码是:
CKEDITOR.replace('mail_content');
CKEDITOR.config.toolbar = [
['Styles','Format','Font','FontSize'],
// '/',
['Bold','Italic','Underline','StrikeThrough','-','Undo','Redo','-','Cut','Copy','Paste','Find','Replace','-','Outdent','Indent','-','Print'],
// '/',
['NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Flash','TextColor','BGColor']
] ;
按钮是
<button name="edit" id="edit" >edit</button>
答案 0 :(得分:1)
我不完全明白你需要什么,但如果你需要例子,请看这个
<textarea name="mail_content" id="mail_content" rows="10" cols="80">
This is a test
</textarea>
<button name="edit" id="edit" >edit</button>
<script>
$('#edit').click(function(){
CKEDITOR.editorConfig = function (config) {
config.language = 'es';
config.uiColor = '#F7B42C';
config.height = 300;
config.toolbarCanCollapse = true;
config.toolbar = [
['Styles','Format','Font','FontSize'],
// '/',
['Bold','Italic','Underline','StrikeThrough','-','Undo','Redo','-','Cut','Copy','Paste','Find','Replace','-','Outdent','Indent','-','Print'],
// '/',
['NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Flash','TextColor','BGColor']
] ;
};
CKEDITOR.replace('mail_content');
});
</script>
答案 1 :(得分:0)
使用insertHtml:
CKEDITOR.instances.mail_content.insertHtml('<p>dsfds</p>');