在按钮上插入数据点击ckeditor
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在按钮上插入数据点击ckeditor相关的知识,希望对你有一定的参考价值。
我必须使用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>
答案
我不完全明白你需要什么,但如果你需要例子看看这个
<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>
https://jsfiddle.net/reoh7j74/527
另一答案
使用insertHtml:
CKEDITOR.instances.mail_content.insertHtml('<p>dsfds</p>');
以上是关于在按钮上插入数据点击ckeditor的主要内容,如果未能解决你的问题,请参考以下文章