通过jquery将图像附加到ckeditor [英] append an image to ckeditor via jquery
本文介绍了通过jquery将图像附加到ckeditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ckeditor在网站上添加帖子:
I'm using ckeditor to add posts at a site:
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
当我点击按钮时,我想将一些文字或图像追加到它的文本区域jquery。
and I want to append some text or image to the textarea of it when I click at a button via jquery.
我试过这个但没有用过:
I tried this but not worked:
<script>
$(document).ready(function(){
$('.button').click(function(){
img = "<img src='http://localhost/sdn/files/uploads/1368647314.png'/>'";
$(".cke_editable").append(img); // also I tried: $("#editor1").append(img);
});
});
</script>
谢谢。
推荐答案
使用 CKEditor API :
<script>
$(document).ready(function(){
$('.button').click(function(){
img = "<img src='http://localhost/sdn/files/uploads/1368647314.png'/>'";
CKEDITOR.instances.editor1.insertHtml(img);
});
});
</script>
这篇关于通过jquery将图像附加到ckeditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文