首页 > 其他分享 >kindeditor 富文本编辑器

kindeditor 富文本编辑器

时间:2022-12-11 02:35:00浏览次数:76  
标签:function 文本编辑 name kindeditor editor input click

原文链接:https://www.cnblogs.com/hzyhx/p/11067265.html

第一步:打开网站http://kindeditor.net/demo.php

第二步:点击default.html(默认模式)

 

 

第三步:建一个文件夹,----文件名叫kindeditor 的使用

第四步:在文件kindeditor 的使用中建一个css和js文件夹

第五步:打开网站http://kindeditor.net/ke4/examples/default.html后,【右击】、【查看网页源代码(V)】

 

 

第六步:打开notepad++,将刚复制的代码放到notepad++中,语言选择html,保存为index

第七步:删除以下代码

K('input[name=getHtml]').click(function(e) {
                    alert(editor.html());
                });
                K('input[name=isEmpty]').click(function(e) {
                    alert(editor.isEmpty());
                });
                K('input[name=getText]').click(function(e) {
                    alert(editor.text());
                });
                K('input[name=selectedHtml]').click(function(e) {
                    alert(editor.selectedHtml());
                });
                K('input[name=setHtml]').click(function(e) {
                    editor.html('<h3>Hello KindEditor</h3>');
                });
                K('input[name=setText]').click(function(e) {
                    editor.text('<h3>Hello KindEditor</h3>');
                });
                K('input[name=insertHtml]').click(function(e) {
                    editor.insertHtml('<strong>插入HTML</strong>');
                });
                K('input[name=appendHtml]').click(function(e) {
                    editor.appendHtml('<strong>添加HTML</strong>');
                });
                K('input[name=clear]').click(function(e) {
                    editor.html('');
                });

第八步:到kindeditor网站中下载样式

 

  第九步:引入样式:

<link rel="stylesheet" href="kindeditor/themes/default/default.css" />
<script charset="utf-8" src="kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="kindeditor/lang/zh-CN.js"></script>

完整代码:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Default Examples</title>
        <style>
            form {
                margin: 0;
            }
            textarea {
                display: block;
            }
        </style>
        <link rel="stylesheet" href="kindeditor/themes/default/default.css" />
        <script charset="utf-8" src="kindeditor/kindeditor-all-min.js"></script>
        <script charset="utf-8" src="kindeditor/lang/zh-CN.js"></script>
        <script>
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('textarea[name="content"]', {
                    allowFileManager : true
                });
            });
        </script>
    </head>
    <body>
        <script type="text/javascript"><!--
        google_ad_client = "ca-pub-7116729301372758";
        /* 更多演示(728x90) */
        google_ad_slot = "5052271949";
        google_ad_width = 728;
        google_ad_height = 90;
        //-->
        </script>
        <script type="text/javascript"
        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
        <h3>默认模式</h3>
        <form>
            <textarea name="content" style="width:800px;height:400px;visibility:hidden;">KindEditor</textarea>
        </form>
    </body>
</html>

运行结果:

 

标签:function,文本编辑,name,kindeditor,editor,input,click
From: https://www.cnblogs.com/zhu4c4/p/16972736.html

相关文章