zoukankan      html  css  js  c++  java
  • 富文本的原理和插件使用

    富文本的原理:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>富文本</title>
        <style>
            #box{
                 300px;
                height: 300px;
                border: 1px solid #ccc;
            }
        </style>
    </head>
    <body>
        <button onclick="boldHandler()">加粗</button>
        <button onclick="italicHandler()">倾斜</button>
        <button onclick="colorHandler()">颜色</button>
        <div contenteditable id="box"></div>
        
        <!-- 引入富文本 -->
        <script src="https://unpkg.com/wangeditor@3.1.1/release/wangEditor.min.js"></script>
        <script>
            function boldHandler(){
                document.execCommand("bold");
            }
    
            function italicHandler(){
                document.execCommand("italic");
            }
    
            function colorHandler(){
                document.execCommand("foreColor",null,"deeppink");
            }
        </script>
    </body>
    </html>

      效果:

    插件使用:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>富文本</title>
    </head>
    <body>
        <div id="editor">
            <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p>
        </div>
        <!-- 引入富文本 -->
        <script src="https://unpkg.com/wangeditor@3.1.1/release/wangEditor.min.js"></script>
        <script type="text/javascript">
            var E = window.wangEditor
            var editor = new E('#editor')
            // 或者 var editor = new E( document.getElementById('editor') )
            editor.create()
        </script>
    </body>
    </html>

      效果:

  • 相关阅读:
    ssh端口转发
    linux git命令安装
    linux git命令
    linux cpio命令
    linux 抓包工具
    js 深拷贝 ,浅拷贝
    vue $router 打开新窗口
    excel常用操作
    Kafka Topic的增删改查操作
    linux上删除文件名乱码的文件
  • 原文地址:https://www.cnblogs.com/wuqilang/p/11977122.html
Copyright © 2011-2022 走看看