富文本编辑器wangEditor

 wangEditor是基于JavaScript和css开发的Web富文本编辑器。

wangEditor的使用:

 引入wangEditor组件

 

 

 wangEditor的读取与写入操作

 

 

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--引入wangEditor-->
    <script src="/resources/wangEditor.min.js"></script>
</head>
<body>
    <div >
        <button id="btnRead">读取内容</button>
        <button id="btnWrite">写入内容</button>
    </div>
    <div id="divEditor" style="width: 800px;height: 600px"></div>
    <script>
        var E = window.wangEditor;
        var editor = new E("#divEditor");//完成富文本编辑器初始化
        editor.create();//创建富文本编辑器,显示在页面上
        document.getElementById("btnRead").onclick = function () {
            var content = editor.txt.html();//获取编辑器现有的html内容
            alert(content);
        }
        document.getElementById("btnWrite").onclick = function (){
            var content = "<li style='color:red'>我是<b>新内容</b></li>";
            editor.txt.html(content);//设置编辑器的内容
        }
    </script>
</body>
</html>
复制代码

 

posted @   南风知君  阅读(1300)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示