kindeditor国内最受欢迎的HTML编辑器

KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。 本文将演示9种不同编辑器方法。

1、默认模式:

<textarea name="content" style="width:800px;height:400px;visibility:hidden;">KindEditor
var editor; 
KindEditor.ready(function(K) 
    editor = K.create('textarea[name="content"]', 
        allowFileManager: true //true或false,true时显示浏览服务器图片功能。 
    }); 
});

2、取得HTML

<input type="button" name="getHtml" value="取得HTML" />
K('input[name=getHtml]').click(function(e) 
    alert(editor.html()); 
});

3、取得文本(包含img,embed)

<input type="button" name="getText" value="取得文本(包含img,embed)" />
K('input[name=getText]').click(function(e) 
    alert(editor.text()); 
});

4、设置HTML

<input type="button" name="setHtml" value="设置HTML" />
K('input[name=setHtml]').click(function(e) 
    editor.html('<h3>Hello KindEditor</h3>'); 
});

5、设置文本

<input type="button" name="setText" value="设置文本" />
K('input[name=setText]').click(function(e) 
    editor.text('<h3>Hello KindEditor</h3>'); 
});

其余4种基础效果请看kindeditor演示效果,代码很简单。

全文:http://www.sucaihuo.com/js/123.html

posted @ 2016-08-18 11:06  stma  阅读(1073)  评论(0)    收藏  举报