kindEditor文本编辑器

  引用js

 <script charset="utf-8" src="jquery.js"></script>
  <script charset="utf-8" src="../kindeditor-min.js"></script>
  <script charset="utf-8" src="../lang/zh_CN.js"></script>
  <script>

  加载
   $(function() {
    var editor = KindEditor.create('textarea[name="content"]');
   });
  </script>

  设置宽高
   <textarea name="content" style="width:800px;height:200px;"></textarea>

   // 以上代码在官方文档就可以看到

 

/** 正常情况只需要一行代码就够了,例:KindEditor.create($(":input[name='input_content']"
** 但有些时候在一个页面需要添加多个文本框,都要用到它,并且不能使用公共变量
** 而且要经常要把后台传过来的值赋给当前的文本框
** 解决办法如下 1.找到kindEditor的局部变量 2.指定区域
**/
// 启用文本编辑器
var $target = $("#xxx");
KindEditor.create($(":input[name='input_content']", $target), {// $target指定区域
width : '100%',
minWidth : '550px',
pasteType : 1,
items : [
'source', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'plainpaste']
});
// 点击后将某个值传给当前文本框
// KindEditor局部变量 $("iframe", $target).contents().find("body")
$("iframe", $target).contents().find("body").html(psource);

 

 

加群QQ226728216

posted @ 2014-05-15 17:47  piter  阅读(275)  评论(0编辑  收藏  举报